Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk update for ums #263

Merged
merged 8 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"log"

"github.com/spotinst/spotinst-sdk-go/service/administration"
"github.com/spotinst/spotinst-sdk-go/service/organization"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
"github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil"
Expand All @@ -22,18 +22,18 @@ func main() {
// 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 := administration.New(sess)
svc := organization.New(sess)

// Create a new context.
ctx := context.Background()

// Create a new group.
out, err := svc.CreatePolicy(ctx, &administration.CreatePolicyInput{
Policy: &administration.Policy{
out, err := svc.CreatePolicy(ctx, &organization.CreatePolicyInput{
Policy: &organization.Policy{
Description: spotinst.String("Automation Policy by Terraform"),
Name: spotinst.String("AutomationPolicy"),
PolicyContent: &administration.PolicyContent{
Statements: []*administration.Statement{
PolicyContent: &organization.PolicyContent{
Statements: []*organization.Statement{
{
Actions: []string{
"ocean:deleteCluster",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"context"
"github.com/spotinst/spotinst-sdk-go/service/administration"
"github.com/spotinst/spotinst-sdk-go/service/organization"
"log"

"github.com/spotinst/spotinst-sdk-go/spotinst"
Expand All @@ -21,13 +21,13 @@ func main() {
// 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 := administration.New(sess)
svc := organization.New(sess)

// Create a new context.
ctx := context.Background()

// Delete an existing group.
_, err := svc.DeletePolicy(ctx, &administration.DeletePolicyInput{
_, err := svc.DeletePolicy(ctx, &organization.DeletePolicyInput{
PolicyID: spotinst.String("pol-abcd1234"),
})
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"context"
"github.com/spotinst/spotinst-sdk-go/service/administration"
"github.com/spotinst/spotinst-sdk-go/service/organization"
"log"

"github.com/spotinst/spotinst-sdk-go/spotinst"
Expand All @@ -22,13 +22,13 @@ func main() {
// 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 := administration.New(sess)
svc := organization.New(sess)

// Create a new context.
ctx := context.Background()

// List all groups.
out, err := svc.ListPolicies(ctx, &administration.ListPoliciesInput{})
out, err := svc.ListPolicies(ctx, &organization.ListPoliciesInput{})
if err != nil {
log.Fatalf("spotinst: failed to list users: %v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"context"
"github.com/spotinst/spotinst-sdk-go/service/administration"
"github.com/spotinst/spotinst-sdk-go/service/organization"
"log"

"github.com/spotinst/spotinst-sdk-go/spotinst"
Expand All @@ -22,13 +22,13 @@ func main() {
// 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 := administration.New(sess)
svc := organization.New(sess)

// Create a new context.
ctx := context.Background()

// Read group configuration.
out, err := svc.ReadPolicy(ctx, &administration.ReadPolicyInput{
out, err := svc.ReadPolicy(ctx, &organization.ReadPolicyInput{
PolicyID: spotinst.String("pol-abcd1234"),
})
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"log"

"github.com/spotinst/spotinst-sdk-go/service/administration"
"github.com/spotinst/spotinst-sdk-go/service/organization"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
"github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil"
Expand All @@ -22,14 +22,14 @@ func main() {
// 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 := administration.New(sess)
svc := organization.New(sess)

// Create a new context.
ctx := context.Background()

// Create a new group.
out, err := svc.UpdatePolicy(ctx, &administration.UpdatePolicyInput{
Policy: &administration.Policy{
out, err := svc.UpdatePolicy(ctx, &organization.UpdatePolicyInput{
Policy: &organization.Policy{
PolicyID: spotinst.String("pol-abcd1234"),
Name: spotinst.String("Automation-Policy-Updated"),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"log"

"github.com/spotinst/spotinst-sdk-go/service/administration"
"github.com/spotinst/spotinst-sdk-go/service/organization"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
"github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil"
Expand All @@ -22,13 +22,13 @@ func main() {
// 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 := administration.New(sess)
svc := organization.New(sess)

// Create a new context.
ctx := context.Background()

// Create a new group.
out, err := svc.CreateUser(ctx, &administration.User{
out, err := svc.CreateUser(ctx, &organization.User{
Email: spotinst.String("testautomation@netapp.com"),
FirstName: spotinst.String("test"),
LastName: spotinst.String("user"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"log"

"github.com/spotinst/spotinst-sdk-go/service/administration"
"github.com/spotinst/spotinst-sdk-go/service/organization"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
"github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil"
Expand All @@ -22,22 +22,22 @@ func main() {
// 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 := administration.New(sess)
svc := organization.New(sess)

// Create a new context.
ctx := context.Background()

// Create a new group.
out, err := svc.CreateProgUser(ctx, &administration.ProgrammaticUser{
out, err := svc.CreateProgUser(ctx, &organization.ProgrammaticUser{
Name: spotinst.String("test-programmatic-user"),
Description: spotinst.String("description"),
Accounts: []*administration.Account{
Accounts: []*organization.Account{
{
Id: spotinst.String("act-a1b2c3d4"),
Role: spotinst.String("viewer"),
},
}, //Accounts and Policies are exclusive
/*Policies: []*administration.ProgPolicy{
/*Policies: []*organization.ProgPolicy{
{
PolicyId: spotinst.String("pol-abcd1234"),
AccountIds: []string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"context"
"github.com/spotinst/spotinst-sdk-go/service/administration"
"github.com/spotinst/spotinst-sdk-go/service/organization"
"log"

"github.com/spotinst/spotinst-sdk-go/spotinst"
Expand All @@ -21,13 +21,13 @@ func main() {
// 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 := administration.New(sess)
svc := organization.New(sess)

// Create a new context.
ctx := context.Background()

// Delete an existing group.
_, err := svc.DeleteUser(ctx, &administration.DeleteUserInput{
_, err := svc.DeleteUser(ctx, &organization.DeleteUserInput{
UserID: spotinst.String("pu-abcd1234"),
})
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"context"
"github.com/spotinst/spotinst-sdk-go/service/administration"
"github.com/spotinst/spotinst-sdk-go/service/organization"
"log"

"github.com/spotinst/spotinst-sdk-go/spotinst"
Expand All @@ -22,13 +22,13 @@ func main() {
// 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 := administration.New(sess)
svc := organization.New(sess)

// Create a new context.
ctx := context.Background()

// List all groups.
out, err := svc.ListUsers(ctx, &administration.ListUsersInput{})
out, err := svc.ListUsers(ctx, &organization.ListUsersInput{})
if err != nil {
log.Fatalf("spotinst: failed to list users: %v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"context"
"github.com/spotinst/spotinst-sdk-go/service/administration"
"github.com/spotinst/spotinst-sdk-go/service/organization"
"log"

"github.com/spotinst/spotinst-sdk-go/spotinst"
Expand All @@ -22,13 +22,13 @@ func main() {
// 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 := administration.New(sess)
svc := organization.New(sess)

// Create a new context.
ctx := context.Background()

// Read group configuration.
out, err := svc.ReadUser(ctx, &administration.ReadUserInput{
out, err := svc.ReadUser(ctx, &organization.ReadUserInput{
UserID: spotinst.String("u-abcd1234"),
})
if err != nil {
Expand Down
52 changes: 52 additions & 0 deletions examples/service/organization/user/updatePolicyMapping/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package main

import (
"context"
"log"

"github.com/spotinst/spotinst-sdk-go/service/organization"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
)

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 := organization.New(sess)

// Create a new context.
ctx := context.Background()

// Create a new group.
err := svc.UpdatePolicyMappingOfUser(ctx, &organization.UpdatePolicyMappingOfUserInput{
UserID: spotinst.String("u-0628514b"),
Policies: []*organization.UserPolicy{
&organization.UserPolicy{
PolicyId: spotinst.String("pol-abcd1234"),
AccountIds: []string{
"act-1234abcd",
},
},
&organization.UserPolicy{
PolicyId: spotinst.String("pol-xyzw1234"),
AccountIds: []string{
"act-abcd1234",
},
},
},
})

if err != nil {
log.Fatalf("spotinst: failed to update policy: %v", err)
}

}
41 changes: 41 additions & 0 deletions examples/service/organization/user/updateUserGroupMapping/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"context"
"log"

"github.com/spotinst/spotinst-sdk-go/service/organization"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
)

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 := organization.New(sess)

// Create a new context.
ctx := context.Background()

// Create a new group.
err := svc.UpdateUserGroupMappingOfUser(ctx, &organization.UpdateUserGroupMappingOfUserInput{
UserID: spotinst.String("u-abcd1234"),
UserGroupIds: []string{
"ugr-abcd1234",
},
})

if err != nil {
log.Fatalf("spotinst: failed to update policy: %v", err)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"log"

"github.com/spotinst/spotinst-sdk-go/service/administration"
"github.com/spotinst/spotinst-sdk-go/service/organization"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
"github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil"
Expand All @@ -22,19 +22,19 @@ func main() {
// 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 := administration.New(sess)
svc := organization.New(sess)

// Create a new context.
ctx := context.Background()

// Create a new group.
out, err := svc.CreateUserGroup(ctx, &administration.UserGroup{
out, err := svc.CreateUserGroup(ctx, &organization.UserGroup{
Description: spotinst.String("TFUserGroup"),
Name: spotinst.String("test-user-group"),
UserIds: []string{
"u-abcd1234",
},
Policies: []*administration.UserGroupPolicy{
Policies: []*organization.UserGroupPolicy{
{
AccountIds: []string{
"act-abcd1234",
Expand Down
Loading
Loading