-
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.
feature: new service: data integration (#178)
- Loading branch information
1 parent
cca1ca2
commit e75dd8b
Showing
8 changed files
with
621 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
examples/service/dataintegration/providers/aws/create/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,51 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/spotinst/spotinst-sdk-go/service/dataintegration" | ||
"github.com/spotinst/spotinst-sdk-go/service/dataintegration/providers/aws" | ||
"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 := dataintegration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Create a new Data Integration. | ||
out, err := svc.CloudProviderAWS().CreateDataIntegration(ctx, &aws.CreateDataIntegrationInput{ | ||
DataIntegration: &aws.DataIntegration{ | ||
Name: spotinst.String("my-s3-integration-check"), | ||
Vendor: spotinst.String("s3"), | ||
Config: &aws.Config{ | ||
BucketName: spotinst.String("foo"), | ||
SubDir: spotinst.String("foo"), | ||
}, | ||
}, | ||
}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to create data integration: %v", err) | ||
} | ||
|
||
// Output. | ||
if out.DataIntegration != nil { | ||
log.Printf("Data Integration %q: %s", | ||
spotinst.StringValue(out.DataIntegration.ID), | ||
stringutil.Stringify(out.DataIntegration)) | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
examples/service/dataintegration/providers/aws/delete/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,36 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/spotinst/spotinst-sdk-go/service/dataintegration" | ||
"github.com/spotinst/spotinst-sdk-go/service/dataintegration/providers/aws" | ||
"github.com/spotinst/spotinst-sdk-go/spotinst" | ||
"github.com/spotinst/spotinst-sdk-go/spotinst/session" | ||
"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 := dataintegration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Delete an existing data integration. | ||
_, err := svc.CloudProviderAWS().DeleteDataIntegration(ctx, &aws.DeleteDataIntegrationInput{ | ||
DataIntegrationId: spotinst.String("di-12345"), | ||
}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to delete data integration: %v", err) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
examples/service/dataintegration/providers/aws/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,44 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/spotinst/spotinst-sdk-go/service/dataintegration" | ||
"github.com/spotinst/spotinst-sdk-go/service/dataintegration/providers/aws" | ||
"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 := dataintegration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// List all data integrations. | ||
out, err := svc.CloudProviderAWS().ListDataIntegration(ctx, &aws.ListDataIntegrationsInput{}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to list data integrations: %v", err) | ||
} | ||
|
||
// Output all data integrations, if any. | ||
if len(out.DataIntegrations) > 0 { | ||
for _, dataIntegration := range out.DataIntegrations { | ||
log.Printf("Data Integration %q: %s", | ||
spotinst.StringValue(dataIntegration.ID), | ||
stringutil.Stringify(dataIntegration)) | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
examples/service/dataintegration/providers/aws/read/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,44 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/spotinst/spotinst-sdk-go/service/dataintegration" | ||
"github.com/spotinst/spotinst-sdk-go/service/dataintegration/providers/aws" | ||
"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 := dataintegration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Read data integration configuration. | ||
out, err := svc.CloudProviderAWS().ReadDataIntegration(ctx, &aws.ReadDataIntegrationInput{ | ||
DataIntegrationId: spotinst.String("di-12345"), | ||
}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to read data integration: %v", err) | ||
} | ||
|
||
// Output. | ||
if out.DataIntegration != nil { | ||
log.Printf("Data Integration %q: %s", | ||
spotinst.StringValue(out.DataIntegration.ID), | ||
stringutil.Stringify(out.DataIntegration)) | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
examples/service/dataintegration/providers/aws/update/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,50 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/spotinst/spotinst-sdk-go/service/dataintegration" | ||
"github.com/spotinst/spotinst-sdk-go/service/dataintegration/providers/aws" | ||
"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 := dataintegration.New(sess) | ||
|
||
// Create a new context. | ||
ctx := context.Background() | ||
|
||
// Update data integration configuration. | ||
out, err := svc.CloudProviderAWS().UpdateDataIntegration(ctx, &aws.UpdateDataIntegrationInput{ | ||
DataIntegration: &aws.DataIntegration{ | ||
ID: spotinst.String("di-12345"), | ||
Vendor: spotinst.String("s3"), | ||
Config: &aws.Config{ | ||
SubDir: spotinst.String("foo"), | ||
}, | ||
}, | ||
}) | ||
if err != nil { | ||
log.Fatalf("spotinst: failed to update data integration: %v", err) | ||
} | ||
|
||
// Output. | ||
if out.DataIntegration != nil { | ||
log.Printf("Data Integration %q: %s", | ||
spotinst.StringValue(out.DataIntegration.ID), | ||
stringutil.Stringify(out.DataIntegration)) | ||
} | ||
} |
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,37 @@ | ||
package dataintegration | ||
|
||
import ( | ||
"github.com/spotinst/spotinst-sdk-go/service/dataintegration/providers/aws" | ||
"github.com/spotinst/spotinst-sdk-go/spotinst" | ||
"github.com/spotinst/spotinst-sdk-go/spotinst/client" | ||
"github.com/spotinst/spotinst-sdk-go/spotinst/session" | ||
) | ||
|
||
// Service provides the API operation methods for making requests to endpoints | ||
// of the Spotinst API. See this package's package overview docs for details on | ||
// the service. | ||
type Service interface { | ||
CloudProviderAWS() aws.Service | ||
} | ||
|
||
type ServiceOp struct { | ||
Client *client.Client | ||
} | ||
|
||
var _ Service = &ServiceOp{} | ||
|
||
func New(sess *session.Session, cfgs ...*spotinst.Config) *ServiceOp { | ||
cfg := &spotinst.Config{} | ||
cfg.Merge(sess.Config) | ||
cfg.Merge(cfgs...) | ||
|
||
return &ServiceOp{ | ||
Client: client.New(cfg), | ||
} | ||
} | ||
|
||
func (s *ServiceOp) CloudProviderAWS() aws.Service { | ||
return &aws.ServiceOp{ | ||
Client: s.Client, | ||
} | ||
} |
Oops, something went wrong.