-
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.
Fix(Ocean/Spark) - Add list VNGs API (#222)
- Loading branch information
1 parent
4ad43e8
commit a6201a9
Showing
5 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
examples/service/ocean/spark/virtualNodeGroup/list/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,47 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/spotinst/spotinst-sdk-go/service/ocean" | ||
"github.com/spotinst/spotinst-sdk-go/service/ocean/spark" | ||
"github.com/spotinst/spotinst-sdk-go/spotinst" | ||
"github.com/spotinst/spotinst-sdk-go/spotinst/session" | ||
"github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil" | ||
) | ||
|
||
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() | ||
|
||
// List dedicated VNGs. | ||
out, err := svc.Spark().ListVirtualNodeGroups(ctx, &spark.ListVngsInput{ | ||
ClusterID: spotinst.String("osc-12345"), | ||
}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to list VNGs: %v", err) | ||
} | ||
|
||
// Output dedicated VNGs, if any. | ||
if len(out.VirtualNodeGroups) > 0 { | ||
for _, vng := range out.VirtualNodeGroups { | ||
log.Printf("VNG %q: %s", | ||
spotinst.StringValue(vng.VngID), | ||
stringutil.Stringify(vng)) | ||
} | ||
} | ||
} |
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
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