github.com/aavshr/aws-sdk-go@v1.41.3/service/servicediscovery/examples_test.go (about)

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package servicediscovery_test
     4  
     5  import (
     6  	"fmt"
     7  	"strings"
     8  	"time"
     9  
    10  	"github.com/aavshr/aws-sdk-go/aws"
    11  	"github.com/aavshr/aws-sdk-go/aws/awserr"
    12  	"github.com/aavshr/aws-sdk-go/aws/session"
    13  	"github.com/aavshr/aws-sdk-go/service/servicediscovery"
    14  )
    15  
    16  var _ time.Duration
    17  var _ strings.Reader
    18  var _ aws.Config
    19  
    20  func parseTime(layout, value string) *time.Time {
    21  	t, err := time.Parse(layout, value)
    22  	if err != nil {
    23  		panic(err)
    24  	}
    25  	return &t
    26  }
    27  
    28  // CreateHttpNamespace example
    29  //
    30  // This example creates an HTTP namespace.
    31  func ExampleServiceDiscovery_CreateHttpNamespace_shared00() {
    32  	svc := servicediscovery.New(session.New())
    33  	input := &servicediscovery.CreateHttpNamespaceInput{
    34  		CreatorRequestId: aws.String("example-creator-request-id-0001"),
    35  		Description:      aws.String("Example.com AWS Cloud Map HTTP Namespace"),
    36  		Name:             aws.String("example-http.com"),
    37  	}
    38  
    39  	result, err := svc.CreateHttpNamespace(input)
    40  	if err != nil {
    41  		if aerr, ok := err.(awserr.Error); ok {
    42  			switch aerr.Code() {
    43  			case servicediscovery.ErrCodeInvalidInput:
    44  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
    45  			case servicediscovery.ErrCodeNamespaceAlreadyExists:
    46  				fmt.Println(servicediscovery.ErrCodeNamespaceAlreadyExists, aerr.Error())
    47  			case servicediscovery.ErrCodeResourceLimitExceeded:
    48  				fmt.Println(servicediscovery.ErrCodeResourceLimitExceeded, aerr.Error())
    49  			case servicediscovery.ErrCodeDuplicateRequest:
    50  				fmt.Println(servicediscovery.ErrCodeDuplicateRequest, aerr.Error())
    51  			case servicediscovery.ErrCodeTooManyTagsException:
    52  				fmt.Println(servicediscovery.ErrCodeTooManyTagsException, aerr.Error())
    53  			default:
    54  				fmt.Println(aerr.Error())
    55  			}
    56  		} else {
    57  			// Print the error, cast err to awserr.Error to get the Code and
    58  			// Message from an error.
    59  			fmt.Println(err.Error())
    60  		}
    61  		return
    62  	}
    63  
    64  	fmt.Println(result)
    65  }
    66  
    67  // Example: Create private DNS namespace
    68  //
    69  // Example: Create private DNS namespace
    70  func ExampleServiceDiscovery_CreatePrivateDnsNamespace_shared00() {
    71  	svc := servicediscovery.New(session.New())
    72  	input := &servicediscovery.CreatePrivateDnsNamespaceInput{
    73  		CreatorRequestId: aws.String("eedd6892-50f3-41b2-8af9-611d6e1d1a8c"),
    74  		Name:             aws.String("example.com"),
    75  		Vpc:              aws.String("vpc-1c56417b"),
    76  	}
    77  
    78  	result, err := svc.CreatePrivateDnsNamespace(input)
    79  	if err != nil {
    80  		if aerr, ok := err.(awserr.Error); ok {
    81  			switch aerr.Code() {
    82  			case servicediscovery.ErrCodeInvalidInput:
    83  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
    84  			case servicediscovery.ErrCodeNamespaceAlreadyExists:
    85  				fmt.Println(servicediscovery.ErrCodeNamespaceAlreadyExists, aerr.Error())
    86  			case servicediscovery.ErrCodeResourceLimitExceeded:
    87  				fmt.Println(servicediscovery.ErrCodeResourceLimitExceeded, aerr.Error())
    88  			case servicediscovery.ErrCodeDuplicateRequest:
    89  				fmt.Println(servicediscovery.ErrCodeDuplicateRequest, aerr.Error())
    90  			case servicediscovery.ErrCodeTooManyTagsException:
    91  				fmt.Println(servicediscovery.ErrCodeTooManyTagsException, aerr.Error())
    92  			default:
    93  				fmt.Println(aerr.Error())
    94  			}
    95  		} else {
    96  			// Print the error, cast err to awserr.Error to get the Code and
    97  			// Message from an error.
    98  			fmt.Println(err.Error())
    99  		}
   100  		return
   101  	}
   102  
   103  	fmt.Println(result)
   104  }
   105  
   106  // CreatePublicDnsNamespace example
   107  //
   108  // This example creates a public namespace based on DNS.
   109  func ExampleServiceDiscovery_CreatePublicDnsNamespace_shared00() {
   110  	svc := servicediscovery.New(session.New())
   111  	input := &servicediscovery.CreatePublicDnsNamespaceInput{
   112  		CreatorRequestId: aws.String("example-creator-request-id-0003"),
   113  		Description:      aws.String("Example.com AWS Cloud Map Public DNS Namespace"),
   114  		Name:             aws.String("example-public-dns.com"),
   115  	}
   116  
   117  	result, err := svc.CreatePublicDnsNamespace(input)
   118  	if err != nil {
   119  		if aerr, ok := err.(awserr.Error); ok {
   120  			switch aerr.Code() {
   121  			case servicediscovery.ErrCodeInvalidInput:
   122  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   123  			case servicediscovery.ErrCodeNamespaceAlreadyExists:
   124  				fmt.Println(servicediscovery.ErrCodeNamespaceAlreadyExists, aerr.Error())
   125  			case servicediscovery.ErrCodeResourceLimitExceeded:
   126  				fmt.Println(servicediscovery.ErrCodeResourceLimitExceeded, aerr.Error())
   127  			case servicediscovery.ErrCodeDuplicateRequest:
   128  				fmt.Println(servicediscovery.ErrCodeDuplicateRequest, aerr.Error())
   129  			case servicediscovery.ErrCodeTooManyTagsException:
   130  				fmt.Println(servicediscovery.ErrCodeTooManyTagsException, aerr.Error())
   131  			default:
   132  				fmt.Println(aerr.Error())
   133  			}
   134  		} else {
   135  			// Print the error, cast err to awserr.Error to get the Code and
   136  			// Message from an error.
   137  			fmt.Println(err.Error())
   138  		}
   139  		return
   140  	}
   141  
   142  	fmt.Println(result)
   143  }
   144  
   145  // Example: Create service
   146  //
   147  // Example: Create service
   148  func ExampleServiceDiscovery_CreateService_shared00() {
   149  	svc := servicediscovery.New(session.New())
   150  	input := &servicediscovery.CreateServiceInput{
   151  		CreatorRequestId: aws.String("567c1193-6b00-4308-bd57-ad38a8822d25"),
   152  		DnsConfig: &servicediscovery.DnsConfig{
   153  			DnsRecords: []*servicediscovery.DnsRecord{
   154  				{
   155  					TTL:  aws.Int64(60),
   156  					Type: aws.String("A"),
   157  				},
   158  			},
   159  			NamespaceId:   aws.String("ns-ylexjili4cdxy3xm"),
   160  			RoutingPolicy: aws.String("MULTIVALUE"),
   161  		},
   162  		Name:        aws.String("myservice"),
   163  		NamespaceId: aws.String("ns-ylexjili4cdxy3xm"),
   164  	}
   165  
   166  	result, err := svc.CreateService(input)
   167  	if err != nil {
   168  		if aerr, ok := err.(awserr.Error); ok {
   169  			switch aerr.Code() {
   170  			case servicediscovery.ErrCodeInvalidInput:
   171  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   172  			case servicediscovery.ErrCodeResourceLimitExceeded:
   173  				fmt.Println(servicediscovery.ErrCodeResourceLimitExceeded, aerr.Error())
   174  			case servicediscovery.ErrCodeNamespaceNotFound:
   175  				fmt.Println(servicediscovery.ErrCodeNamespaceNotFound, aerr.Error())
   176  			case servicediscovery.ErrCodeServiceAlreadyExists:
   177  				fmt.Println(servicediscovery.ErrCodeServiceAlreadyExists, aerr.Error())
   178  			case servicediscovery.ErrCodeTooManyTagsException:
   179  				fmt.Println(servicediscovery.ErrCodeTooManyTagsException, aerr.Error())
   180  			default:
   181  				fmt.Println(aerr.Error())
   182  			}
   183  		} else {
   184  			// Print the error, cast err to awserr.Error to get the Code and
   185  			// Message from an error.
   186  			fmt.Println(err.Error())
   187  		}
   188  		return
   189  	}
   190  
   191  	fmt.Println(result)
   192  }
   193  
   194  // Example: Delete namespace
   195  //
   196  // Example: Delete namespace
   197  func ExampleServiceDiscovery_DeleteNamespace_shared00() {
   198  	svc := servicediscovery.New(session.New())
   199  	input := &servicediscovery.DeleteNamespaceInput{
   200  		Id: aws.String("ns-ylexjili4cdxy3xm"),
   201  	}
   202  
   203  	result, err := svc.DeleteNamespace(input)
   204  	if err != nil {
   205  		if aerr, ok := err.(awserr.Error); ok {
   206  			switch aerr.Code() {
   207  			case servicediscovery.ErrCodeInvalidInput:
   208  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   209  			case servicediscovery.ErrCodeNamespaceNotFound:
   210  				fmt.Println(servicediscovery.ErrCodeNamespaceNotFound, aerr.Error())
   211  			case servicediscovery.ErrCodeResourceInUse:
   212  				fmt.Println(servicediscovery.ErrCodeResourceInUse, aerr.Error())
   213  			case servicediscovery.ErrCodeDuplicateRequest:
   214  				fmt.Println(servicediscovery.ErrCodeDuplicateRequest, aerr.Error())
   215  			default:
   216  				fmt.Println(aerr.Error())
   217  			}
   218  		} else {
   219  			// Print the error, cast err to awserr.Error to get the Code and
   220  			// Message from an error.
   221  			fmt.Println(err.Error())
   222  		}
   223  		return
   224  	}
   225  
   226  	fmt.Println(result)
   227  }
   228  
   229  // Example: Delete service
   230  //
   231  // Example: Delete service
   232  func ExampleServiceDiscovery_DeleteService_shared00() {
   233  	svc := servicediscovery.New(session.New())
   234  	input := &servicediscovery.DeleteServiceInput{
   235  		Id: aws.String("srv-p5zdwlg5uvvzjita"),
   236  	}
   237  
   238  	result, err := svc.DeleteService(input)
   239  	if err != nil {
   240  		if aerr, ok := err.(awserr.Error); ok {
   241  			switch aerr.Code() {
   242  			case servicediscovery.ErrCodeInvalidInput:
   243  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   244  			case servicediscovery.ErrCodeServiceNotFound:
   245  				fmt.Println(servicediscovery.ErrCodeServiceNotFound, aerr.Error())
   246  			case servicediscovery.ErrCodeResourceInUse:
   247  				fmt.Println(servicediscovery.ErrCodeResourceInUse, aerr.Error())
   248  			default:
   249  				fmt.Println(aerr.Error())
   250  			}
   251  		} else {
   252  			// Print the error, cast err to awserr.Error to get the Code and
   253  			// Message from an error.
   254  			fmt.Println(err.Error())
   255  		}
   256  		return
   257  	}
   258  
   259  	fmt.Println(result)
   260  }
   261  
   262  // Example: Deregister a service instance
   263  //
   264  // Example: Deregister a service instance
   265  func ExampleServiceDiscovery_DeregisterInstance_shared00() {
   266  	svc := servicediscovery.New(session.New())
   267  	input := &servicediscovery.DeregisterInstanceInput{
   268  		InstanceId: aws.String("myservice-53"),
   269  		ServiceId:  aws.String("srv-p5zdwlg5uvvzjita"),
   270  	}
   271  
   272  	result, err := svc.DeregisterInstance(input)
   273  	if err != nil {
   274  		if aerr, ok := err.(awserr.Error); ok {
   275  			switch aerr.Code() {
   276  			case servicediscovery.ErrCodeDuplicateRequest:
   277  				fmt.Println(servicediscovery.ErrCodeDuplicateRequest, aerr.Error())
   278  			case servicediscovery.ErrCodeInvalidInput:
   279  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   280  			case servicediscovery.ErrCodeInstanceNotFound:
   281  				fmt.Println(servicediscovery.ErrCodeInstanceNotFound, aerr.Error())
   282  			case servicediscovery.ErrCodeResourceInUse:
   283  				fmt.Println(servicediscovery.ErrCodeResourceInUse, aerr.Error())
   284  			case servicediscovery.ErrCodeServiceNotFound:
   285  				fmt.Println(servicediscovery.ErrCodeServiceNotFound, aerr.Error())
   286  			default:
   287  				fmt.Println(aerr.Error())
   288  			}
   289  		} else {
   290  			// Print the error, cast err to awserr.Error to get the Code and
   291  			// Message from an error.
   292  			fmt.Println(err.Error())
   293  		}
   294  		return
   295  	}
   296  
   297  	fmt.Println(result)
   298  }
   299  
   300  // Example: Discover registered instances
   301  //
   302  // Example: Discover registered instances
   303  func ExampleServiceDiscovery_DiscoverInstances_shared00() {
   304  	svc := servicediscovery.New(session.New())
   305  	input := &servicediscovery.DiscoverInstancesInput{
   306  		HealthStatus:  aws.String("ALL"),
   307  		MaxResults:    aws.Int64(10),
   308  		NamespaceName: aws.String("example.com"),
   309  		ServiceName:   aws.String("myservice"),
   310  	}
   311  
   312  	result, err := svc.DiscoverInstances(input)
   313  	if err != nil {
   314  		if aerr, ok := err.(awserr.Error); ok {
   315  			switch aerr.Code() {
   316  			case servicediscovery.ErrCodeServiceNotFound:
   317  				fmt.Println(servicediscovery.ErrCodeServiceNotFound, aerr.Error())
   318  			case servicediscovery.ErrCodeNamespaceNotFound:
   319  				fmt.Println(servicediscovery.ErrCodeNamespaceNotFound, aerr.Error())
   320  			case servicediscovery.ErrCodeInvalidInput:
   321  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   322  			case servicediscovery.ErrCodeRequestLimitExceeded:
   323  				fmt.Println(servicediscovery.ErrCodeRequestLimitExceeded, aerr.Error())
   324  			default:
   325  				fmt.Println(aerr.Error())
   326  			}
   327  		} else {
   328  			// Print the error, cast err to awserr.Error to get the Code and
   329  			// Message from an error.
   330  			fmt.Println(err.Error())
   331  		}
   332  		return
   333  	}
   334  
   335  	fmt.Println(result)
   336  }
   337  
   338  // GetInstance example
   339  //
   340  // This example gets information about a specified instance.
   341  func ExampleServiceDiscovery_GetInstance_shared00() {
   342  	svc := servicediscovery.New(session.New())
   343  	input := &servicediscovery.GetInstanceInput{
   344  		InstanceId: aws.String("i-abcd1234"),
   345  		ServiceId:  aws.String("srv-e4anhexample0004"),
   346  	}
   347  
   348  	result, err := svc.GetInstance(input)
   349  	if err != nil {
   350  		if aerr, ok := err.(awserr.Error); ok {
   351  			switch aerr.Code() {
   352  			case servicediscovery.ErrCodeInstanceNotFound:
   353  				fmt.Println(servicediscovery.ErrCodeInstanceNotFound, aerr.Error())
   354  			case servicediscovery.ErrCodeInvalidInput:
   355  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   356  			case servicediscovery.ErrCodeServiceNotFound:
   357  				fmt.Println(servicediscovery.ErrCodeServiceNotFound, aerr.Error())
   358  			default:
   359  				fmt.Println(aerr.Error())
   360  			}
   361  		} else {
   362  			// Print the error, cast err to awserr.Error to get the Code and
   363  			// Message from an error.
   364  			fmt.Println(err.Error())
   365  		}
   366  		return
   367  	}
   368  
   369  	fmt.Println(result)
   370  }
   371  
   372  // GetInstancesHealthStatus example
   373  //
   374  // This example gets the current health status of one or more instances that are associate
   375  // with a specified service.
   376  func ExampleServiceDiscovery_GetInstancesHealthStatus_shared00() {
   377  	svc := servicediscovery.New(session.New())
   378  	input := &servicediscovery.GetInstancesHealthStatusInput{
   379  		ServiceId: aws.String("srv-e4anhexample0004"),
   380  	}
   381  
   382  	result, err := svc.GetInstancesHealthStatus(input)
   383  	if err != nil {
   384  		if aerr, ok := err.(awserr.Error); ok {
   385  			switch aerr.Code() {
   386  			case servicediscovery.ErrCodeInstanceNotFound:
   387  				fmt.Println(servicediscovery.ErrCodeInstanceNotFound, aerr.Error())
   388  			case servicediscovery.ErrCodeInvalidInput:
   389  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   390  			case servicediscovery.ErrCodeServiceNotFound:
   391  				fmt.Println(servicediscovery.ErrCodeServiceNotFound, aerr.Error())
   392  			default:
   393  				fmt.Println(aerr.Error())
   394  			}
   395  		} else {
   396  			// Print the error, cast err to awserr.Error to get the Code and
   397  			// Message from an error.
   398  			fmt.Println(err.Error())
   399  		}
   400  		return
   401  	}
   402  
   403  	fmt.Println(result)
   404  }
   405  
   406  // GetNamespace example
   407  //
   408  // This example gets information about a specified namespace.
   409  func ExampleServiceDiscovery_GetNamespace_shared00() {
   410  	svc := servicediscovery.New(session.New())
   411  	input := &servicediscovery.GetNamespaceInput{
   412  		Id: aws.String("ns-e4anhexample0004"),
   413  	}
   414  
   415  	result, err := svc.GetNamespace(input)
   416  	if err != nil {
   417  		if aerr, ok := err.(awserr.Error); ok {
   418  			switch aerr.Code() {
   419  			case servicediscovery.ErrCodeInvalidInput:
   420  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   421  			case servicediscovery.ErrCodeNamespaceNotFound:
   422  				fmt.Println(servicediscovery.ErrCodeNamespaceNotFound, aerr.Error())
   423  			default:
   424  				fmt.Println(aerr.Error())
   425  			}
   426  		} else {
   427  			// Print the error, cast err to awserr.Error to get the Code and
   428  			// Message from an error.
   429  			fmt.Println(err.Error())
   430  		}
   431  		return
   432  	}
   433  
   434  	fmt.Println(result)
   435  }
   436  
   437  // Example: Get operation result
   438  //
   439  // Example: Get operation result
   440  func ExampleServiceDiscovery_GetOperation_shared00() {
   441  	svc := servicediscovery.New(session.New())
   442  	input := &servicediscovery.GetOperationInput{
   443  		OperationId: aws.String("gv4g5meo7ndmeh4fqskygvk23d2fijwa-k9302yzd"),
   444  	}
   445  
   446  	result, err := svc.GetOperation(input)
   447  	if err != nil {
   448  		if aerr, ok := err.(awserr.Error); ok {
   449  			switch aerr.Code() {
   450  			case servicediscovery.ErrCodeInvalidInput:
   451  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   452  			case servicediscovery.ErrCodeOperationNotFound:
   453  				fmt.Println(servicediscovery.ErrCodeOperationNotFound, aerr.Error())
   454  			default:
   455  				fmt.Println(aerr.Error())
   456  			}
   457  		} else {
   458  			// Print the error, cast err to awserr.Error to get the Code and
   459  			// Message from an error.
   460  			fmt.Println(err.Error())
   461  		}
   462  		return
   463  	}
   464  
   465  	fmt.Println(result)
   466  }
   467  
   468  // GetService Example
   469  //
   470  // This example gets the settings for a specified service.
   471  func ExampleServiceDiscovery_GetService_shared00() {
   472  	svc := servicediscovery.New(session.New())
   473  	input := &servicediscovery.GetServiceInput{
   474  		Id: aws.String("srv-e4anhexample0004"),
   475  	}
   476  
   477  	result, err := svc.GetService(input)
   478  	if err != nil {
   479  		if aerr, ok := err.(awserr.Error); ok {
   480  			switch aerr.Code() {
   481  			case servicediscovery.ErrCodeInvalidInput:
   482  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   483  			case servicediscovery.ErrCodeServiceNotFound:
   484  				fmt.Println(servicediscovery.ErrCodeServiceNotFound, aerr.Error())
   485  			default:
   486  				fmt.Println(aerr.Error())
   487  			}
   488  		} else {
   489  			// Print the error, cast err to awserr.Error to get the Code and
   490  			// Message from an error.
   491  			fmt.Println(err.Error())
   492  		}
   493  		return
   494  	}
   495  
   496  	fmt.Println(result)
   497  }
   498  
   499  // Example: List service instances
   500  //
   501  // Example: List service instances
   502  func ExampleServiceDiscovery_ListInstances_shared00() {
   503  	svc := servicediscovery.New(session.New())
   504  	input := &servicediscovery.ListInstancesInput{
   505  		ServiceId: aws.String("srv-qzpwvt2tfqcegapy"),
   506  	}
   507  
   508  	result, err := svc.ListInstances(input)
   509  	if err != nil {
   510  		if aerr, ok := err.(awserr.Error); ok {
   511  			switch aerr.Code() {
   512  			case servicediscovery.ErrCodeServiceNotFound:
   513  				fmt.Println(servicediscovery.ErrCodeServiceNotFound, aerr.Error())
   514  			case servicediscovery.ErrCodeInvalidInput:
   515  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   516  			default:
   517  				fmt.Println(aerr.Error())
   518  			}
   519  		} else {
   520  			// Print the error, cast err to awserr.Error to get the Code and
   521  			// Message from an error.
   522  			fmt.Println(err.Error())
   523  		}
   524  		return
   525  	}
   526  
   527  	fmt.Println(result)
   528  }
   529  
   530  // Example: List namespaces
   531  //
   532  // Example: List namespaces
   533  func ExampleServiceDiscovery_ListNamespaces_shared00() {
   534  	svc := servicediscovery.New(session.New())
   535  	input := &servicediscovery.ListNamespacesInput{}
   536  
   537  	result, err := svc.ListNamespaces(input)
   538  	if err != nil {
   539  		if aerr, ok := err.(awserr.Error); ok {
   540  			switch aerr.Code() {
   541  			case servicediscovery.ErrCodeInvalidInput:
   542  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   543  			default:
   544  				fmt.Println(aerr.Error())
   545  			}
   546  		} else {
   547  			// Print the error, cast err to awserr.Error to get the Code and
   548  			// Message from an error.
   549  			fmt.Println(err.Error())
   550  		}
   551  		return
   552  	}
   553  
   554  	fmt.Println(result)
   555  }
   556  
   557  // ListOperations Example
   558  //
   559  // This example gets the operations that have a STATUS of either PENDING or SUCCESS.
   560  func ExampleServiceDiscovery_ListOperations_shared00() {
   561  	svc := servicediscovery.New(session.New())
   562  	input := &servicediscovery.ListOperationsInput{
   563  		Filters: []*servicediscovery.OperationFilter{
   564  			{
   565  				Condition: aws.String("IN"),
   566  				Name:      aws.String("STATUS"),
   567  				Values: []*string{
   568  					aws.String("PENDING"),
   569  					aws.String("SUCCESS"),
   570  				},
   571  			},
   572  		},
   573  	}
   574  
   575  	result, err := svc.ListOperations(input)
   576  	if err != nil {
   577  		if aerr, ok := err.(awserr.Error); ok {
   578  			switch aerr.Code() {
   579  			case servicediscovery.ErrCodeInvalidInput:
   580  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   581  			default:
   582  				fmt.Println(aerr.Error())
   583  			}
   584  		} else {
   585  			// Print the error, cast err to awserr.Error to get the Code and
   586  			// Message from an error.
   587  			fmt.Println(err.Error())
   588  		}
   589  		return
   590  	}
   591  
   592  	fmt.Println(result)
   593  }
   594  
   595  // Example: List services
   596  //
   597  // Example: List services
   598  func ExampleServiceDiscovery_ListServices_shared00() {
   599  	svc := servicediscovery.New(session.New())
   600  	input := &servicediscovery.ListServicesInput{}
   601  
   602  	result, err := svc.ListServices(input)
   603  	if err != nil {
   604  		if aerr, ok := err.(awserr.Error); ok {
   605  			switch aerr.Code() {
   606  			case servicediscovery.ErrCodeInvalidInput:
   607  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   608  			default:
   609  				fmt.Println(aerr.Error())
   610  			}
   611  		} else {
   612  			// Print the error, cast err to awserr.Error to get the Code and
   613  			// Message from an error.
   614  			fmt.Println(err.Error())
   615  		}
   616  		return
   617  	}
   618  
   619  	fmt.Println(result)
   620  }
   621  
   622  // ListTagsForResource example
   623  //
   624  // This example lists the tags of a resource.
   625  func ExampleServiceDiscovery_ListTagsForResource_shared00() {
   626  	svc := servicediscovery.New(session.New())
   627  	input := &servicediscovery.ListTagsForResourceInput{
   628  		ResourceARN: aws.String("arn:aws:servicediscovery:us-east-1:123456789012:namespace/ns-ylexjili4cdxy3xm"),
   629  	}
   630  
   631  	result, err := svc.ListTagsForResource(input)
   632  	if err != nil {
   633  		if aerr, ok := err.(awserr.Error); ok {
   634  			switch aerr.Code() {
   635  			case servicediscovery.ErrCodeResourceNotFoundException:
   636  				fmt.Println(servicediscovery.ErrCodeResourceNotFoundException, aerr.Error())
   637  			case servicediscovery.ErrCodeInvalidInput:
   638  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   639  			default:
   640  				fmt.Println(aerr.Error())
   641  			}
   642  		} else {
   643  			// Print the error, cast err to awserr.Error to get the Code and
   644  			// Message from an error.
   645  			fmt.Println(err.Error())
   646  		}
   647  		return
   648  	}
   649  
   650  	fmt.Println(result)
   651  }
   652  
   653  // Example: Register Instance
   654  //
   655  // Example: Register Instance
   656  func ExampleServiceDiscovery_RegisterInstance_shared00() {
   657  	svc := servicediscovery.New(session.New())
   658  	input := &servicediscovery.RegisterInstanceInput{
   659  		Attributes: map[string]*string{
   660  			"AWS_INSTANCE_IPV4": aws.String("172.2.1.3"),
   661  			"AWS_INSTANCE_PORT": aws.String("808"),
   662  		},
   663  		CreatorRequestId: aws.String("7a48a98a-72e6-4849-bfa7-1a458e030d7b"),
   664  		InstanceId:       aws.String("myservice-53"),
   665  		ServiceId:        aws.String("srv-p5zdwlg5uvvzjita"),
   666  	}
   667  
   668  	result, err := svc.RegisterInstance(input)
   669  	if err != nil {
   670  		if aerr, ok := err.(awserr.Error); ok {
   671  			switch aerr.Code() {
   672  			case servicediscovery.ErrCodeDuplicateRequest:
   673  				fmt.Println(servicediscovery.ErrCodeDuplicateRequest, aerr.Error())
   674  			case servicediscovery.ErrCodeInvalidInput:
   675  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   676  			case servicediscovery.ErrCodeResourceInUse:
   677  				fmt.Println(servicediscovery.ErrCodeResourceInUse, aerr.Error())
   678  			case servicediscovery.ErrCodeResourceLimitExceeded:
   679  				fmt.Println(servicediscovery.ErrCodeResourceLimitExceeded, aerr.Error())
   680  			case servicediscovery.ErrCodeServiceNotFound:
   681  				fmt.Println(servicediscovery.ErrCodeServiceNotFound, aerr.Error())
   682  			default:
   683  				fmt.Println(aerr.Error())
   684  			}
   685  		} else {
   686  			// Print the error, cast err to awserr.Error to get the Code and
   687  			// Message from an error.
   688  			fmt.Println(err.Error())
   689  		}
   690  		return
   691  	}
   692  
   693  	fmt.Println(result)
   694  }
   695  
   696  // TagResource example
   697  //
   698  // This example adds "Department" and "Project" tags to a resource.
   699  func ExampleServiceDiscovery_TagResource_shared00() {
   700  	svc := servicediscovery.New(session.New())
   701  	input := &servicediscovery.TagResourceInput{
   702  		ResourceARN: aws.String("arn:aws:servicediscovery:us-east-1:123456789012:namespace/ns-ylexjili4cdxy3xm"),
   703  		Tags: []*servicediscovery.Tag{
   704  			{
   705  				Key:   aws.String("Department"),
   706  				Value: aws.String("Engineering"),
   707  			},
   708  			{
   709  				Key:   aws.String("Project"),
   710  				Value: aws.String("Zeta"),
   711  			},
   712  		},
   713  	}
   714  
   715  	result, err := svc.TagResource(input)
   716  	if err != nil {
   717  		if aerr, ok := err.(awserr.Error); ok {
   718  			switch aerr.Code() {
   719  			case servicediscovery.ErrCodeResourceNotFoundException:
   720  				fmt.Println(servicediscovery.ErrCodeResourceNotFoundException, aerr.Error())
   721  			case servicediscovery.ErrCodeTooManyTagsException:
   722  				fmt.Println(servicediscovery.ErrCodeTooManyTagsException, aerr.Error())
   723  			case servicediscovery.ErrCodeInvalidInput:
   724  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   725  			default:
   726  				fmt.Println(aerr.Error())
   727  			}
   728  		} else {
   729  			// Print the error, cast err to awserr.Error to get the Code and
   730  			// Message from an error.
   731  			fmt.Println(err.Error())
   732  		}
   733  		return
   734  	}
   735  
   736  	fmt.Println(result)
   737  }
   738  
   739  // UntagResource example
   740  //
   741  // This example removes the "Department" and "Project" tags from a resource.
   742  func ExampleServiceDiscovery_UntagResource_shared00() {
   743  	svc := servicediscovery.New(session.New())
   744  	input := &servicediscovery.UntagResourceInput{
   745  		ResourceARN: aws.String("arn:aws:servicediscovery:us-east-1:123456789012:namespace/ns-ylexjili4cdxy3xm"),
   746  		TagKeys: []*string{
   747  			aws.String("Project"),
   748  			aws.String("Department"),
   749  		},
   750  	}
   751  
   752  	result, err := svc.UntagResource(input)
   753  	if err != nil {
   754  		if aerr, ok := err.(awserr.Error); ok {
   755  			switch aerr.Code() {
   756  			case servicediscovery.ErrCodeResourceNotFoundException:
   757  				fmt.Println(servicediscovery.ErrCodeResourceNotFoundException, aerr.Error())
   758  			case servicediscovery.ErrCodeInvalidInput:
   759  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   760  			default:
   761  				fmt.Println(aerr.Error())
   762  			}
   763  		} else {
   764  			// Print the error, cast err to awserr.Error to get the Code and
   765  			// Message from an error.
   766  			fmt.Println(err.Error())
   767  		}
   768  		return
   769  	}
   770  
   771  	fmt.Println(result)
   772  }
   773  
   774  // UpdateInstanceCustomHealthStatus Example
   775  //
   776  // This example submits a request to change the health status of an instance associated
   777  // with a service with a custom health check to HEALTHY.
   778  func ExampleServiceDiscovery_UpdateInstanceCustomHealthStatus_shared00() {
   779  	svc := servicediscovery.New(session.New())
   780  	input := &servicediscovery.UpdateInstanceCustomHealthStatusInput{
   781  		InstanceId: aws.String("i-abcd1234"),
   782  		ServiceId:  aws.String("srv-e4anhexample0004"),
   783  		Status:     aws.String("HEALTHY"),
   784  	}
   785  
   786  	result, err := svc.UpdateInstanceCustomHealthStatus(input)
   787  	if err != nil {
   788  		if aerr, ok := err.(awserr.Error); ok {
   789  			switch aerr.Code() {
   790  			case servicediscovery.ErrCodeInstanceNotFound:
   791  				fmt.Println(servicediscovery.ErrCodeInstanceNotFound, aerr.Error())
   792  			case servicediscovery.ErrCodeServiceNotFound:
   793  				fmt.Println(servicediscovery.ErrCodeServiceNotFound, aerr.Error())
   794  			case servicediscovery.ErrCodeCustomHealthNotFound:
   795  				fmt.Println(servicediscovery.ErrCodeCustomHealthNotFound, aerr.Error())
   796  			case servicediscovery.ErrCodeInvalidInput:
   797  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   798  			default:
   799  				fmt.Println(aerr.Error())
   800  			}
   801  		} else {
   802  			// Print the error, cast err to awserr.Error to get the Code and
   803  			// Message from an error.
   804  			fmt.Println(err.Error())
   805  		}
   806  		return
   807  	}
   808  
   809  	fmt.Println(result)
   810  }
   811  
   812  // UpdateService Example
   813  //
   814  // This example submits a request to replace the DnsConfig and HealthCheckConfig settings
   815  // of a specified service.
   816  func ExampleServiceDiscovery_UpdateService_shared00() {
   817  	svc := servicediscovery.New(session.New())
   818  	input := &servicediscovery.UpdateServiceInput{
   819  		Id: aws.String("srv-e4anhexample0004"),
   820  		Service: &servicediscovery.ServiceChange{
   821  			DnsConfig: &servicediscovery.DnsConfigChange{
   822  				DnsRecords: []*servicediscovery.DnsRecord{
   823  					{
   824  						TTL:  aws.Int64(60),
   825  						Type: aws.String("A"),
   826  					},
   827  				},
   828  			},
   829  			HealthCheckConfig: &servicediscovery.HealthCheckConfig{
   830  				FailureThreshold: aws.Int64(2),
   831  				ResourcePath:     aws.String("/"),
   832  				Type:             aws.String("HTTP"),
   833  			},
   834  		},
   835  	}
   836  
   837  	result, err := svc.UpdateService(input)
   838  	if err != nil {
   839  		if aerr, ok := err.(awserr.Error); ok {
   840  			switch aerr.Code() {
   841  			case servicediscovery.ErrCodeDuplicateRequest:
   842  				fmt.Println(servicediscovery.ErrCodeDuplicateRequest, aerr.Error())
   843  			case servicediscovery.ErrCodeInvalidInput:
   844  				fmt.Println(servicediscovery.ErrCodeInvalidInput, aerr.Error())
   845  			case servicediscovery.ErrCodeServiceNotFound:
   846  				fmt.Println(servicediscovery.ErrCodeServiceNotFound, aerr.Error())
   847  			default:
   848  				fmt.Println(aerr.Error())
   849  			}
   850  		} else {
   851  			// Print the error, cast err to awserr.Error to get the Code and
   852  			// Message from an error.
   853  			fmt.Println(err.Error())
   854  		}
   855  		return
   856  	}
   857  
   858  	fmt.Println(result)
   859  }