-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for "GetWorkloadsAttached" for rightsizing rule
- Loading branch information
1 parent
1b86c76
commit 828fe73
Showing
3 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
examples/service/ocean/right_sizing/getWorkloadsAttached/main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/spotinst/spotinst-sdk-go/service/ocean" | ||
"github.com/spotinst/spotinst-sdk-go/service/ocean/right_sizing" | ||
"github.com/spotinst/spotinst-sdk-go/spotinst" | ||
"github.com/spotinst/spotinst-sdk-go/spotinst/session" | ||
"github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil" | ||
"log" | ||
) | ||
|
||
func main() { | ||
// All clients require a Session. The Session provides the client with | ||
// shared configuration such as account and credentials. | ||
// A Session should be shared where possible to take advantage of | ||
// configuration and credential caching. See the session package for | ||
// more information. | ||
sess := session.New() | ||
|
||
// Create a new instance of the service's client with a Session. | ||
// Optional spotinst.Config values can also be provided as variadic | ||
// arguments to the New function. This option allows you to provide | ||
// service specific configuration. | ||
svc := ocean.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Read an existing right sizing rule | ||
out, err := svc.RightSizing().GetWorkloadsAttached(ctx, &right_sizing.GetWorkloadsAttachedInput{ | ||
RuleName: spotinst.String("demo-rule"), | ||
OceanId: spotinst.String("o-123456"), | ||
}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to read attached workload: %v", err) | ||
} | ||
|
||
// Output. | ||
if out.Workloads != nil { | ||
log.Printf("Workloads %q", | ||
stringutil.Stringify(out.Workloads)) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters