本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/elasticsearchservice.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ExampleElasticsearchService_AddTags
func ExampleElasticsearchService_AddTags() {
svc := elasticsearchservice.New(session.New())
params := &elasticsearchservice.AddTagsInput{
ARN: aws.String("ARN"), // Required
TagList: []*elasticsearchservice.Tag{ // Required
{ // Required
Key: aws.String("TagKey"), // Required
Value: aws.String("TagValue"), // Required
},
// More values...
},
}
resp, err := svc.AddTags(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例2: ExampleElasticsearchService_RemoveTags
func ExampleElasticsearchService_RemoveTags() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := elasticsearchservice.New(sess)
params := &elasticsearchservice.RemoveTagsInput{
ARN: aws.String("ARN"), // Required
TagKeys: []*string{ // Required
aws.String("String"), // Required
// More values...
},
}
resp, err := svc.RemoveTags(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例3: ExampleElasticsearchService_ListDomainNames
func ExampleElasticsearchService_ListDomainNames() {
svc := elasticsearchservice.New(session.New())
var params *elasticsearchservice.ListDomainNamesInput
resp, err := svc.ListDomainNames(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例4: ExampleElasticsearchService_CreateElasticsearchDomain
func ExampleElasticsearchService_CreateElasticsearchDomain() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := elasticsearchservice.New(sess)
params := &elasticsearchservice.CreateElasticsearchDomainInput{
DomainName: aws.String("DomainName"), // Required
AccessPolicies: aws.String("PolicyDocument"),
AdvancedOptions: map[string]*string{
"Key": aws.String("String"), // Required
// More values...
},
EBSOptions: &elasticsearchservice.EBSOptions{
EBSEnabled: aws.Bool(true),
Iops: aws.Int64(1),
VolumeSize: aws.Int64(1),
VolumeType: aws.String("VolumeType"),
},
ElasticsearchClusterConfig: &elasticsearchservice.ElasticsearchClusterConfig{
DedicatedMasterCount: aws.Int64(1),
DedicatedMasterEnabled: aws.Bool(true),
DedicatedMasterType: aws.String("ESPartitionInstanceType"),
InstanceCount: aws.Int64(1),
InstanceType: aws.String("ESPartitionInstanceType"),
ZoneAwarenessEnabled: aws.Bool(true),
},
ElasticsearchVersion: aws.String("ElasticsearchVersionString"),
SnapshotOptions: &elasticsearchservice.SnapshotOptions{
AutomatedSnapshotStartHour: aws.Int64(1),
},
}
resp, err := svc.CreateElasticsearchDomain(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例5: ExampleElasticsearchService_DeleteElasticsearchDomain
func ExampleElasticsearchService_DeleteElasticsearchDomain() {
svc := elasticsearchservice.New(session.New())
params := &elasticsearchservice.DeleteElasticsearchDomainInput{
DomainName: aws.String("DomainName"), // Required
}
resp, err := svc.DeleteElasticsearchDomain(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例6: ExampleElasticsearchService_ListTags
func ExampleElasticsearchService_ListTags() {
svc := elasticsearchservice.New(session.New())
params := &elasticsearchservice.ListTagsInput{
ARN: aws.String("ARN"), // Required
}
resp, err := svc.ListTags(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例7: Process
func Process(ctx context.Context, region string) {
ctx.Print(" Processing elastic search resources...")
svc := elasticsearchservice.New(ctx.AwsSession, &aws.Config{Region: aws.String(region)})
processARNs := func(resourceIds []*string) {
nextWindow := func(ids []*string) ([]*string, []*string) {
w := int(math.Min(float64(len(ids)), float64(200)))
return ids[0:w], ids[w:]
}
for thisRound, remaining := nextWindow(resourceIds); len(thisRound) > 0; thisRound, remaining = nextWindow(remaining) {
updateTags(ctx, *svc, thisRound)
deleteTags(ctx, *svc, thisRound)
printTags(ctx, *svc, thisRound)
}
}
processARNs(getArns(svc))
}
示例8: ExampleElasticsearchService_DescribeElasticsearchDomains
func ExampleElasticsearchService_DescribeElasticsearchDomains() {
svc := elasticsearchservice.New(nil)
params := &elasticsearchservice.DescribeElasticsearchDomainsInput{
DomainNames: []*string{ // Required
aws.String("DomainName"), // Required
// More values...
},
}
resp, err := svc.DescribeElasticsearchDomains(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例9: ExampleElasticsearchService_DescribeElasticsearchDomainConfig
func ExampleElasticsearchService_DescribeElasticsearchDomainConfig() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := elasticsearchservice.New(sess)
params := &elasticsearchservice.DescribeElasticsearchDomainConfigInput{
DomainName: aws.String("DomainName"), // Required
}
resp, err := svc.DescribeElasticsearchDomainConfig(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例10: init
func init() {
Before("@es", func() {
World["client"] = elasticsearchservice.New(smoke.Session)
})
}
示例11: Client
// Client configures and returns a fully initialized AWSClient
func (c *Config) Client() (interface{}, error) {
// Get the auth and region. This can fail if keys/regions were not
// specified and we're attempting to use the environment.
log.Println("[INFO] Building AWS region structure")
err := c.ValidateRegion()
if err != nil {
return nil, err
}
var client AWSClient
// store AWS region in client struct, for region specific operations such as
// bucket storage in S3
client.region = c.Region
log.Println("[INFO] Building AWS auth structure")
creds, err := GetCredentials(c)
if err != nil {
return nil, err
}
// Call Get to check for credential provider. If nothing found, we'll get an
// error, and we can present it nicely to the user
cp, err := creds.Get()
if err != nil {
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NoCredentialProviders" {
return nil, errors.New(`No valid credential sources found for AWS Provider.
Please see https://terraform.io/docs/providers/aws/index.html for more information on
providing credentials for the AWS Provider`)
}
return nil, fmt.Errorf("Error loading credentials for AWS Provider: %s", err)
}
log.Printf("[INFO] AWS Auth provider used: %q", cp.ProviderName)
awsConfig := &aws.Config{
Credentials: creds,
Region: aws.String(c.Region),
MaxRetries: aws.Int(c.MaxRetries),
HTTPClient: cleanhttp.DefaultClient(),
S3ForcePathStyle: aws.Bool(c.S3ForcePathStyle),
}
if logging.IsDebugOrHigher() {
awsConfig.LogLevel = aws.LogLevel(aws.LogDebugWithHTTPBody)
awsConfig.Logger = awsLogger{}
}
if c.Insecure {
transport := awsConfig.HTTPClient.Transport.(*http.Transport)
transport.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true,
}
}
// Set up base session
sess, err := session.NewSession(awsConfig)
if err != nil {
return nil, errwrap.Wrapf("Error creating AWS session: {{err}}", err)
}
// Removes the SDK Version handler, so we only have the provider User-Agent
// Ex: "User-Agent: APN/1.0 HashiCorp/1.0 Terraform/0.7.9-dev"
sess.Handlers.Build.Remove(request.NamedHandler{Name: "core.SDKVersionUserAgentHandler"})
sess.Handlers.Build.PushFrontNamed(addTerraformVersionToUserAgent)
if extraDebug := os.Getenv("TERRAFORM_AWS_AUTHFAILURE_DEBUG"); extraDebug != "" {
sess.Handlers.UnmarshalError.PushFrontNamed(debugAuthFailure)
}
// Some services exist only in us-east-1, e.g. because they manage
// resources that can span across multiple regions, or because
// signature format v4 requires region to be us-east-1 for global
// endpoints:
// http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html
usEast1Sess := sess.Copy(&aws.Config{Region: aws.String("us-east-1")})
// Some services have user-configurable endpoints
awsEc2Sess := sess.Copy(&aws.Config{Endpoint: aws.String(c.Ec2Endpoint)})
awsElbSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.ElbEndpoint)})
awsIamSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.IamEndpoint)})
awsS3Sess := sess.Copy(&aws.Config{Endpoint: aws.String(c.S3Endpoint)})
dynamoSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.DynamoDBEndpoint)})
kinesisSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.KinesisEndpoint)})
// These two services need to be set up early so we can check on AccountID
client.iamconn = iam.New(awsIamSess)
client.stsconn = sts.New(sess)
if !c.SkipCredsValidation {
err = c.ValidateCredentials(client.stsconn)
if err != nil {
return nil, err
}
}
if !c.SkipRequestingAccountId {
partition, accountId, err := GetAccountInfo(client.iamconn, client.stsconn, cp.ProviderName)
if err == nil {
client.partition = partition
//.........這裏部分代碼省略.........
示例12: Client
// Client configures and returns a fully initialized AWSClient
func (c *Config) Client() (interface{}, error) {
var client AWSClient
// Get the auth and region. This can fail if keys/regions were not
// specified and we're attempting to use the environment.
var errs []error
log.Println("[INFO] Building AWS region structure")
err := c.ValidateRegion()
if err != nil {
errs = append(errs, err)
}
if len(errs) == 0 {
// store AWS region in client struct, for region specific operations such as
// bucket storage in S3
client.region = c.Region
log.Println("[INFO] Building AWS auth structure")
// We fetched all credential sources in Provider. If they are
// available, they'll already be in c. See Provider definition.
creds := credentials.NewStaticCredentials(c.AccessKey, c.SecretKey, c.Token)
awsConfig := &aws.Config{
Credentials: creds,
Region: aws.String(c.Region),
MaxRetries: aws.Int(c.MaxRetries),
}
log.Println("[INFO] Initializing IAM Connection")
client.iamconn = iam.New(awsConfig)
err := c.ValidateCredentials(client.iamconn)
if err != nil {
errs = append(errs, err)
}
awsDynamoDBConfig := &aws.Config{
Credentials: creds,
Region: aws.String(c.Region),
MaxRetries: aws.Int(c.MaxRetries),
Endpoint: aws.String(c.DynamoDBEndpoint),
}
// Some services exist only in us-east-1, e.g. because they manage
// resources that can span across multiple regions, or because
// signature format v4 requires region to be us-east-1 for global
// endpoints:
// http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html
usEast1AwsConfig := &aws.Config{
Credentials: creds,
Region: aws.String("us-east-1"),
MaxRetries: aws.Int(c.MaxRetries),
}
log.Println("[INFO] Initializing DynamoDB connection")
client.dynamodbconn = dynamodb.New(awsDynamoDBConfig)
log.Println("[INFO] Initializing ELB connection")
client.elbconn = elb.New(awsConfig)
log.Println("[INFO] Initializing S3 connection")
client.s3conn = s3.New(awsConfig)
log.Println("[INFO] Initializing SQS connection")
client.sqsconn = sqs.New(awsConfig)
log.Println("[INFO] Initializing SNS connection")
client.snsconn = sns.New(awsConfig)
log.Println("[INFO] Initializing RDS Connection")
client.rdsconn = rds.New(awsConfig)
log.Println("[INFO] Initializing Kinesis Connection")
client.kinesisconn = kinesis.New(awsConfig)
authErr := c.ValidateAccountId(client.iamconn)
if authErr != nil {
errs = append(errs, authErr)
}
log.Println("[INFO] Initializing AutoScaling connection")
client.autoscalingconn = autoscaling.New(awsConfig)
log.Println("[INFO] Initializing EC2 Connection")
client.ec2conn = ec2.New(awsConfig)
log.Println("[INFO] Initializing ECS Connection")
client.ecsconn = ecs.New(awsConfig)
log.Println("[INFO] Initializing EFS Connection")
client.efsconn = efs.New(awsConfig)
log.Println("[INFO] Initializing ElasticSearch Connection")
client.esconn = elasticsearch.New(awsConfig)
log.Println("[INFO] Initializing Route 53 connection")
client.r53conn = route53.New(usEast1AwsConfig)
log.Println("[INFO] Initializing Elasticache Connection")
client.elasticacheconn = elasticache.New(awsConfig)
//.........這裏部分代碼省略.........
示例13: init
var (
// Version The version of the application (set by make file)
Version = "UNKNOWN"
cmdRoot = &cobra.Command{
Use: "aws-ek-setup",
Short: "Manage AWS Elasticsearch Clusters",
Long: ``,
}
rootOpts struct {
AWSDebug bool
}
elasticSearchSvc = elasticsearchservice.New(newAWSConfig())
iamSvc = iam.New(newAWSConfig())
)
func init() {
cmdRoot.PersistentFlags().BoolVar(&rootOpts.AWSDebug, "aws-debug", false, "Log debug information from aws-sdk-go library")
}
func main() {
cmdRoot.Execute()
}
func newAWSConfig() *aws.Config {
c := aws.NewConfig()
if rootOpts.AWSDebug {
c = c.WithLogLevel(aws.LogDebug)
示例14: TestInterface
func TestInterface(t *testing.T) {
assert.Implements(t, (*elasticsearchserviceiface.ElasticsearchServiceAPI)(nil), elasticsearchservice.New(nil))
}
示例15: init
func init() {
Before("@es", func() {
World["client"] = elasticsearchservice.New(nil)
})
}