-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support to get workload attached to rightSizing rule. (#328)
- Loading branch information
1 parent
e9de40f
commit b11169e
Showing
3 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
examples/service/ocean/right_sizing/readAttachedWorkloads/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,43 @@ | ||
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().ReadRightsizingRuleAttachedWorkloads(ctx, &right_sizing.ReadRightsizingRuleAttachedWorkloadsInput{ | ||
RuleName: spotinst.String("test-rule"), | ||
OceanId: spotinst.String("o-123456"), | ||
}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to read the right sizing rule: %v", err) | ||
} | ||
// Output. | ||
if out.RightsizingRuleAttachedWorkloads != nil { | ||
log.Printf("Attached workloads : %s", | ||
stringutil.Stringify(out.RightsizingRuleAttachedWorkloads)) | ||
} | ||
} |
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