-
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.
feat(accounts/userManagement): Added support for userManagement apis (#…
…258)
- Loading branch information
Showing
19 changed files
with
1,814 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/spotinst/spotinst-sdk-go/service/administration" | ||
"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 := administration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Create a new group. | ||
out, err := svc.CreatePolicy(ctx, &administration.CreatePolicyInput{ | ||
Policy: &administration.Policy{ | ||
Description: spotinst.String("Automation Policy by Terraform"), | ||
Name: spotinst.String("AutomationPolicy"), | ||
PolicyContent: &administration.PolicyContent{ | ||
Statements: []*administration.Statement{ | ||
{ | ||
Actions: []string{ | ||
"ocean:deleteCluster", | ||
"ocean:updateCluster", | ||
}, | ||
Effect: spotinst.String("ALLOW"), | ||
Resources: []string{ | ||
"*", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
if err != nil { | ||
log.Fatalf("spotinst: failed to create policy: %v", err) | ||
} | ||
|
||
// Output. | ||
if out.Policy != nil { | ||
log.Printf("Policy %q: %s", | ||
spotinst.StringValue(out.Policy.PolicyID), | ||
stringutil.Stringify(out.Policy)) | ||
} | ||
} |
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,36 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/spotinst/spotinst-sdk-go/service/administration" | ||
"log" | ||
|
||
"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 := administration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Delete an existing group. | ||
_, err := svc.DeletePolicy(ctx, &administration.DeletePolicyInput{ | ||
PolicyID: spotinst.String("pol-abcd1234"), | ||
}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to delete policy: %v", err) | ||
} | ||
} |
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,44 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/spotinst/spotinst-sdk-go/service/administration" | ||
"log" | ||
|
||
"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 := administration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// List all groups. | ||
out, err := svc.ListPolicies(ctx, &administration.ListPoliciesInput{}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to list users: %v", err) | ||
} | ||
|
||
// Output all groups, if any. | ||
if len(out.Policies) > 0 { | ||
for _, Policy := range out.Policies { | ||
log.Printf("Policy %q: %s", | ||
spotinst.StringValue(Policy.PolicyID), | ||
stringutil.Stringify(Policy)) | ||
} | ||
} | ||
} |
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,44 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/spotinst/spotinst-sdk-go/service/administration" | ||
"log" | ||
|
||
"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 := administration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Read group configuration. | ||
out, err := svc.ReadPolicy(ctx, &administration.ReadPolicyInput{ | ||
PolicyID: spotinst.String("pol-abcd1234"), | ||
}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to read policy: %v", err) | ||
} | ||
|
||
// Output. | ||
if out.Policy != nil { | ||
log.Printf("User %q: %s", | ||
spotinst.StringValue(out.Policy.PolicyID), | ||
stringutil.Stringify(out.Policy)) | ||
} | ||
} |
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,48 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/spotinst/spotinst-sdk-go/service/administration" | ||
"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 := administration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Create a new group. | ||
out, err := svc.UpdatePolicy(ctx, &administration.UpdatePolicyInput{ | ||
Policy: &administration.Policy{ | ||
PolicyID: spotinst.String("pol-abcd1234"), | ||
Name: spotinst.String("Automation-Policy-Updated"), | ||
}, | ||
}) | ||
|
||
if err != nil { | ||
log.Fatalf("spotinst: failed to update policy: %v", err) | ||
} | ||
|
||
// Output. | ||
if out.Policy != nil { | ||
log.Printf("Policy %q: %s", | ||
spotinst.StringValue(out.Policy.PolicyID), | ||
stringutil.Stringify(out.Policy)) | ||
} | ||
} |
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,49 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/spotinst/spotinst-sdk-go/service/administration" | ||
"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 := administration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Create a new group. | ||
out, err := svc.CreateUser(ctx, &administration.User{ | ||
Email: spotinst.String("testautomation@netapp.com"), | ||
FirstName: spotinst.String("test"), | ||
LastName: spotinst.String("user"), | ||
Password: spotinst.String("testUser@123"), | ||
Role: spotinst.String("viewer"), | ||
}, spotinst.Bool(true)) | ||
|
||
if err != nil { | ||
log.Fatalf("spotinst: failed to create user: %v", err) | ||
} | ||
|
||
// Output. | ||
if out.User != nil { | ||
log.Printf("User %q: %s", | ||
spotinst.StringValue(out.User.UserID), | ||
stringutil.Stringify(out.User)) | ||
} | ||
} |
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,60 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/spotinst/spotinst-sdk-go/service/administration" | ||
"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 := administration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Create a new group. | ||
out, err := svc.CreateProgUser(ctx, &administration.ProgrammaticUser{ | ||
Name: spotinst.String("test-programmatic-user"), | ||
Description: spotinst.String("description"), | ||
Accounts: []*administration.Account{ | ||
{ | ||
Id: spotinst.String("act-a1b2c3d4"), | ||
Role: spotinst.String("viewer"), | ||
}, | ||
}, //Accounts and Policies are exclusive | ||
/*Policies: []*administration.ProgPolicy{ | ||
{ | ||
PolicyId: spotinst.String("pol-abcd1234"), | ||
AccountIds: []string{ | ||
"act-a1b2c3d4", | ||
}, | ||
}, | ||
},*/ | ||
}) | ||
|
||
if err != nil { | ||
log.Fatalf("spotinst: failed to create user: %v", err) | ||
} | ||
|
||
// Output. | ||
if out.ProgrammaticUser != nil { | ||
log.Printf("User %q: %s", | ||
spotinst.StringValue(out.ProgrammaticUser.ProgUserId), | ||
stringutil.Stringify(out.ProgrammaticUser)) | ||
} | ||
} |
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,36 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/spotinst/spotinst-sdk-go/service/administration" | ||
"log" | ||
|
||
"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 := administration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Delete an existing group. | ||
_, err := svc.DeleteUser(ctx, &administration.DeleteUserInput{ | ||
UserID: spotinst.String("pu-abcd1234"), | ||
}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to delete user: %v", err) | ||
} | ||
} |
Oops, something went wrong.