github.com/aavshr/aws-sdk-go@v1.41.3/service/ssmcontacts/examples_test.go (about) 1 // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 3 package ssmcontacts_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/ssmcontacts" 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 // To accept a page during and engagement 29 // 30 // The following accept-page operation uses an accept code sent to the contact channel 31 // to accept a page. 32 func ExampleSSMContacts_AcceptPage_shared00() { 33 svc := ssmcontacts.New(session.New()) 34 input := &ssmcontacts.AcceptPageInput{ 35 AcceptCode: aws.String("425440"), 36 AcceptType: aws.String("READ"), 37 PageId: aws.String("arn:aws:ssm-contacts:us-east-2:682428703967:page/akuam/94ea0c7b-56d9-46c3-b84a-a37c8b067ad3"), 38 } 39 40 result, err := svc.AcceptPage(input) 41 if err != nil { 42 if aerr, ok := err.(awserr.Error); ok { 43 switch aerr.Code() { 44 case ssmcontacts.ErrCodeAccessDeniedException: 45 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 46 case ssmcontacts.ErrCodeInternalServerException: 47 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 48 case ssmcontacts.ErrCodeResourceNotFoundException: 49 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 50 case ssmcontacts.ErrCodeThrottlingException: 51 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 52 case ssmcontacts.ErrCodeValidationException: 53 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 54 default: 55 fmt.Println(aerr.Error()) 56 } 57 } else { 58 // Print the error, cast err to awserr.Error to get the Code and 59 // Message from an error. 60 fmt.Println(err.Error()) 61 } 62 return 63 } 64 65 fmt.Println(result) 66 } 67 68 // Activate a contact's contact channel 69 // 70 // The following activate-contact-channel example activates a contact channel and makes 71 // it usable as part of an incident. 72 func ExampleSSMContacts_ActivateContactChannel_shared00() { 73 svc := ssmcontacts.New(session.New()) 74 input := &ssmcontacts.ActivateContactChannelInput{ 75 ActivationCode: aws.String("466136"), 76 ContactChannelId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact-channel/akuam/fc7405c4-46b2-48b7-87b2-93e2f225b90d"), 77 } 78 79 result, err := svc.ActivateContactChannel(input) 80 if err != nil { 81 if aerr, ok := err.(awserr.Error); ok { 82 switch aerr.Code() { 83 case ssmcontacts.ErrCodeAccessDeniedException: 84 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 85 case ssmcontacts.ErrCodeInternalServerException: 86 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 87 case ssmcontacts.ErrCodeResourceNotFoundException: 88 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 89 case ssmcontacts.ErrCodeThrottlingException: 90 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 91 case ssmcontacts.ErrCodeValidationException: 92 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 93 default: 94 fmt.Println(aerr.Error()) 95 } 96 } else { 97 // Print the error, cast err to awserr.Error to get the Code and 98 // Message from an error. 99 fmt.Println(err.Error()) 100 } 101 return 102 } 103 104 fmt.Println(result) 105 } 106 107 // To create a contact 108 // 109 // The following create-contact example creates a contact in your environment with a 110 // blank plan. The plan can be updated after creating contact channels. Use the create-contact-channel 111 // operation with the output ARN of this command. After you have created contact channels 112 // for this contact use update-contact to update the plan. 113 func ExampleSSMContacts_CreateContact_shared00() { 114 svc := ssmcontacts.New(session.New()) 115 input := &ssmcontacts.CreateContactInput{ 116 Alias: aws.String("akuam"), 117 DisplayName: aws.String("Akua Mansa"), 118 Plan: &ssmcontacts.Plan{}, 119 Type: aws.String("PERSONAL"), 120 } 121 122 result, err := svc.CreateContact(input) 123 if err != nil { 124 if aerr, ok := err.(awserr.Error); ok { 125 switch aerr.Code() { 126 case ssmcontacts.ErrCodeAccessDeniedException: 127 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 128 case ssmcontacts.ErrCodeConflictException: 129 fmt.Println(ssmcontacts.ErrCodeConflictException, aerr.Error()) 130 case ssmcontacts.ErrCodeInternalServerException: 131 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 132 case ssmcontacts.ErrCodeServiceQuotaExceededException: 133 fmt.Println(ssmcontacts.ErrCodeServiceQuotaExceededException, aerr.Error()) 134 case ssmcontacts.ErrCodeThrottlingException: 135 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 136 case ssmcontacts.ErrCodeValidationException: 137 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 138 case ssmcontacts.ErrCodeDataEncryptionException: 139 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 140 default: 141 fmt.Println(aerr.Error()) 142 } 143 } else { 144 // Print the error, cast err to awserr.Error to get the Code and 145 // Message from an error. 146 fmt.Println(err.Error()) 147 } 148 return 149 } 150 151 fmt.Println(result) 152 } 153 154 // To create a contact channel 155 // 156 // Creates a contact channel of type SMS for the contact Akua Mansa. Contact channels 157 // can be created of type SMS, EMAIL, or VOICE. 158 func ExampleSSMContacts_CreateContactChannel_shared00() { 159 svc := ssmcontacts.New(session.New()) 160 input := &ssmcontacts.CreateContactChannelInput{ 161 ContactId: aws.String("arn:aws:ssm-contacts:us-east-1:111122223333:contact/akuam"), 162 DeliveryAddress: &ssmcontacts.ContactChannelAddress{ 163 SimpleAddress: aws.String("+15005550199"), 164 }, 165 Name: aws.String("akuas sms-test"), 166 Type: aws.String("SMS"), 167 } 168 169 result, err := svc.CreateContactChannel(input) 170 if err != nil { 171 if aerr, ok := err.(awserr.Error); ok { 172 switch aerr.Code() { 173 case ssmcontacts.ErrCodeAccessDeniedException: 174 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 175 case ssmcontacts.ErrCodeConflictException: 176 fmt.Println(ssmcontacts.ErrCodeConflictException, aerr.Error()) 177 case ssmcontacts.ErrCodeDataEncryptionException: 178 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 179 case ssmcontacts.ErrCodeInternalServerException: 180 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 181 case ssmcontacts.ErrCodeThrottlingException: 182 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 183 case ssmcontacts.ErrCodeValidationException: 184 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 185 default: 186 fmt.Println(aerr.Error()) 187 } 188 } else { 189 // Print the error, cast err to awserr.Error to get the Code and 190 // Message from an error. 191 fmt.Println(err.Error()) 192 } 193 return 194 } 195 196 fmt.Println(result) 197 } 198 199 // To deactivate a contact channel 200 // 201 // The following ``deactivate-contact-channel`` example deactivates a contact channel. 202 // Deactivating a contact channel means the contact channel will no longer be paged 203 // during an incident. You can also reactivate a contact channel at any time using the 204 // activate-contact-channel operation. 205 func ExampleSSMContacts_DeactivateContactChannel_shared00() { 206 svc := ssmcontacts.New(session.New()) 207 input := &ssmcontacts.DeactivateContactChannelInput{ 208 ContactChannelId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact-channel/akuam/fc7405c4-46b2-48b7-87b2-93e2f225b90d"), 209 } 210 211 result, err := svc.DeactivateContactChannel(input) 212 if err != nil { 213 if aerr, ok := err.(awserr.Error); ok { 214 switch aerr.Code() { 215 case ssmcontacts.ErrCodeAccessDeniedException: 216 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 217 case ssmcontacts.ErrCodeInternalServerException: 218 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 219 case ssmcontacts.ErrCodeResourceNotFoundException: 220 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 221 case ssmcontacts.ErrCodeThrottlingException: 222 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 223 case ssmcontacts.ErrCodeValidationException: 224 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 225 default: 226 fmt.Println(aerr.Error()) 227 } 228 } else { 229 // Print the error, cast err to awserr.Error to get the Code and 230 // Message from an error. 231 fmt.Println(err.Error()) 232 } 233 return 234 } 235 236 fmt.Println(result) 237 } 238 239 // To delete a contact 240 // 241 // The following delete-contact example deletes a contact. The contact will no longer 242 // be reachable from any escalation plan that refers to them. 243 func ExampleSSMContacts_DeleteContact_shared00() { 244 svc := ssmcontacts.New(session.New()) 245 input := &ssmcontacts.DeleteContactInput{ 246 ContactId: aws.String("arn:aws:ssm-contacts:us-east-1:111122223333:contact/alejr"), 247 } 248 249 result, err := svc.DeleteContact(input) 250 if err != nil { 251 if aerr, ok := err.(awserr.Error); ok { 252 switch aerr.Code() { 253 case ssmcontacts.ErrCodeAccessDeniedException: 254 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 255 case ssmcontacts.ErrCodeInternalServerException: 256 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 257 case ssmcontacts.ErrCodeResourceNotFoundException: 258 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 259 case ssmcontacts.ErrCodeThrottlingException: 260 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 261 case ssmcontacts.ErrCodeValidationException: 262 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 263 default: 264 fmt.Println(aerr.Error()) 265 } 266 } else { 267 // Print the error, cast err to awserr.Error to get the Code and 268 // Message from an error. 269 fmt.Println(err.Error()) 270 } 271 return 272 } 273 274 fmt.Println(result) 275 } 276 277 // To delete a contact channel 278 // 279 // The following delete-contact-channel example deletes a contact channel. Deleting 280 // a contact channel ensures the contact channel will not be paged during an incident. 281 func ExampleSSMContacts_DeleteContactChannel_shared00() { 282 svc := ssmcontacts.New(session.New()) 283 input := &ssmcontacts.DeleteContactChannelInput{ 284 ContactChannelId: aws.String("arn:aws:ssm-contacts:us-east-1:111122223333:contact-channel/akuam/13149bad-52ee-45ea-ae1e-45857f78f9b2"), 285 } 286 287 result, err := svc.DeleteContactChannel(input) 288 if err != nil { 289 if aerr, ok := err.(awserr.Error); ok { 290 switch aerr.Code() { 291 case ssmcontacts.ErrCodeAccessDeniedException: 292 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 293 case ssmcontacts.ErrCodeInternalServerException: 294 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 295 case ssmcontacts.ErrCodeResourceNotFoundException: 296 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 297 case ssmcontacts.ErrCodeThrottlingException: 298 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 299 case ssmcontacts.ErrCodeValidationException: 300 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 301 default: 302 fmt.Println(aerr.Error()) 303 } 304 } else { 305 // Print the error, cast err to awserr.Error to get the Code and 306 // Message from an error. 307 fmt.Println(err.Error()) 308 } 309 return 310 } 311 312 fmt.Println(result) 313 } 314 315 // To describe the details of an engagement 316 // 317 // The following describe-engagement example lists the details of an engagement to a 318 // contact or escalation plan. The subject and content are sent to the contact channels. 319 func ExampleSSMContacts_DescribeEngagement_shared00() { 320 svc := ssmcontacts.New(session.New()) 321 input := &ssmcontacts.DescribeEngagementInput{ 322 EngagementId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:engagement/example_escalation/69e40ce1-8dbb-4d57-8962-5fbe7fc53356"), 323 } 324 325 result, err := svc.DescribeEngagement(input) 326 if err != nil { 327 if aerr, ok := err.(awserr.Error); ok { 328 switch aerr.Code() { 329 case ssmcontacts.ErrCodeAccessDeniedException: 330 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 331 case ssmcontacts.ErrCodeDataEncryptionException: 332 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 333 case ssmcontacts.ErrCodeInternalServerException: 334 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 335 case ssmcontacts.ErrCodeResourceNotFoundException: 336 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 337 case ssmcontacts.ErrCodeThrottlingException: 338 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 339 case ssmcontacts.ErrCodeValidationException: 340 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 341 default: 342 fmt.Println(aerr.Error()) 343 } 344 } else { 345 // Print the error, cast err to awserr.Error to get the Code and 346 // Message from an error. 347 fmt.Println(err.Error()) 348 } 349 return 350 } 351 352 fmt.Println(result) 353 } 354 355 // To list the details of a page to a contact channel 356 // 357 // The following describe-page example lists details of a page to a contact channel. 358 // The page will include the subject and content provided. 359 func ExampleSSMContacts_DescribePage_shared00() { 360 svc := ssmcontacts.New(session.New()) 361 input := &ssmcontacts.DescribePageInput{ 362 PageId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:page/akuam/ad0052bd-e606-498a-861b-25726292eb93"), 363 } 364 365 result, err := svc.DescribePage(input) 366 if err != nil { 367 if aerr, ok := err.(awserr.Error); ok { 368 switch aerr.Code() { 369 case ssmcontacts.ErrCodeAccessDeniedException: 370 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 371 case ssmcontacts.ErrCodeDataEncryptionException: 372 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 373 case ssmcontacts.ErrCodeInternalServerException: 374 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 375 case ssmcontacts.ErrCodeResourceNotFoundException: 376 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 377 case ssmcontacts.ErrCodeThrottlingException: 378 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 379 case ssmcontacts.ErrCodeValidationException: 380 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 381 default: 382 fmt.Println(aerr.Error()) 383 } 384 } else { 385 // Print the error, cast err to awserr.Error to get the Code and 386 // Message from an error. 387 fmt.Println(err.Error()) 388 } 389 return 390 } 391 392 fmt.Println(result) 393 } 394 395 // Example 1: To describe a contact plan 396 // 397 // The following get-contact example describes a contact. 398 func ExampleSSMContacts_GetContact_shared00() { 399 svc := ssmcontacts.New(session.New()) 400 input := &ssmcontacts.GetContactInput{ 401 ContactId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact/akuam"), 402 } 403 404 result, err := svc.GetContact(input) 405 if err != nil { 406 if aerr, ok := err.(awserr.Error); ok { 407 switch aerr.Code() { 408 case ssmcontacts.ErrCodeAccessDeniedException: 409 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 410 case ssmcontacts.ErrCodeInternalServerException: 411 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 412 case ssmcontacts.ErrCodeResourceNotFoundException: 413 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 414 case ssmcontacts.ErrCodeThrottlingException: 415 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 416 case ssmcontacts.ErrCodeValidationException: 417 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 418 case ssmcontacts.ErrCodeDataEncryptionException: 419 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 420 default: 421 fmt.Println(aerr.Error()) 422 } 423 } else { 424 // Print the error, cast err to awserr.Error to get the Code and 425 // Message from an error. 426 fmt.Println(err.Error()) 427 } 428 return 429 } 430 431 fmt.Println(result) 432 } 433 434 // Example 2: To describe an escalation plan 435 // 436 // The following get-contact example describes an escalation plan. 437 func ExampleSSMContacts_GetContact_shared01() { 438 svc := ssmcontacts.New(session.New()) 439 input := &ssmcontacts.GetContactInput{ 440 ContactId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact/example_escalation"), 441 } 442 443 result, err := svc.GetContact(input) 444 if err != nil { 445 if aerr, ok := err.(awserr.Error); ok { 446 switch aerr.Code() { 447 case ssmcontacts.ErrCodeAccessDeniedException: 448 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 449 case ssmcontacts.ErrCodeInternalServerException: 450 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 451 case ssmcontacts.ErrCodeResourceNotFoundException: 452 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 453 case ssmcontacts.ErrCodeThrottlingException: 454 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 455 case ssmcontacts.ErrCodeValidationException: 456 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 457 case ssmcontacts.ErrCodeDataEncryptionException: 458 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 459 default: 460 fmt.Println(aerr.Error()) 461 } 462 } else { 463 // Print the error, cast err to awserr.Error to get the Code and 464 // Message from an error. 465 fmt.Println(err.Error()) 466 } 467 return 468 } 469 470 fmt.Println(result) 471 } 472 473 // To list the details of a contact channel 474 // 475 // The following get-contact-channel example lists the details of a contact channel. 476 func ExampleSSMContacts_GetContactChannel_shared00() { 477 svc := ssmcontacts.New(session.New()) 478 input := &ssmcontacts.GetContactChannelInput{ 479 ContactChannelId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact-channel/akuam/fc7405c4-46b2-48b7-87b2-93e2f225b90d"), 480 } 481 482 result, err := svc.GetContactChannel(input) 483 if err != nil { 484 if aerr, ok := err.(awserr.Error); ok { 485 switch aerr.Code() { 486 case ssmcontacts.ErrCodeAccessDeniedException: 487 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 488 case ssmcontacts.ErrCodeDataEncryptionException: 489 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 490 case ssmcontacts.ErrCodeInternalServerException: 491 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 492 case ssmcontacts.ErrCodeResourceNotFoundException: 493 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 494 case ssmcontacts.ErrCodeThrottlingException: 495 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 496 case ssmcontacts.ErrCodeValidationException: 497 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 498 default: 499 fmt.Println(aerr.Error()) 500 } 501 } else { 502 // Print the error, cast err to awserr.Error to get the Code and 503 // Message from an error. 504 fmt.Println(err.Error()) 505 } 506 return 507 } 508 509 fmt.Println(result) 510 } 511 512 // To list the resource policies of a contact 513 // 514 // The following get-contact-policy example lists the resource policies associated with 515 // the specified contact. 516 func ExampleSSMContacts_GetContactPolicy_shared00() { 517 svc := ssmcontacts.New(session.New()) 518 input := &ssmcontacts.GetContactPolicyInput{ 519 ContactArn: aws.String("arn:aws:ssm-contacts:us-east-1:111122223333:contact/akuam"), 520 } 521 522 result, err := svc.GetContactPolicy(input) 523 if err != nil { 524 if aerr, ok := err.(awserr.Error); ok { 525 switch aerr.Code() { 526 case ssmcontacts.ErrCodeAccessDeniedException: 527 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 528 case ssmcontacts.ErrCodeInternalServerException: 529 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 530 case ssmcontacts.ErrCodeResourceNotFoundException: 531 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 532 case ssmcontacts.ErrCodeThrottlingException: 533 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 534 case ssmcontacts.ErrCodeValidationException: 535 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 536 default: 537 fmt.Println(aerr.Error()) 538 } 539 } else { 540 // Print the error, cast err to awserr.Error to get the Code and 541 // Message from an error. 542 fmt.Println(err.Error()) 543 } 544 return 545 } 546 547 fmt.Println(result) 548 } 549 550 // To list the contact channels of a contact 551 // 552 // The following list-contact-channels example lists the available contact channels 553 // of the specified contact. 554 func ExampleSSMContacts_ListContactChannels_shared00() { 555 svc := ssmcontacts.New(session.New()) 556 input := &ssmcontacts.ListContactChannelsInput{ 557 ContactId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact/akuam"), 558 } 559 560 result, err := svc.ListContactChannels(input) 561 if err != nil { 562 if aerr, ok := err.(awserr.Error); ok { 563 switch aerr.Code() { 564 case ssmcontacts.ErrCodeAccessDeniedException: 565 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 566 case ssmcontacts.ErrCodeDataEncryptionException: 567 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 568 case ssmcontacts.ErrCodeInternalServerException: 569 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 570 case ssmcontacts.ErrCodeResourceNotFoundException: 571 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 572 case ssmcontacts.ErrCodeThrottlingException: 573 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 574 case ssmcontacts.ErrCodeValidationException: 575 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 576 default: 577 fmt.Println(aerr.Error()) 578 } 579 } else { 580 // Print the error, cast err to awserr.Error to get the Code and 581 // Message from an error. 582 fmt.Println(err.Error()) 583 } 584 return 585 } 586 587 fmt.Println(result) 588 } 589 590 // To list all escalation plans and contacts 591 // 592 // The following list-contacts example lists the contacts and escalation plans in your 593 // account. 594 func ExampleSSMContacts_ListContacts_shared00() { 595 svc := ssmcontacts.New(session.New()) 596 input := &ssmcontacts.ListContactsInput{} 597 598 result, err := svc.ListContacts(input) 599 if err != nil { 600 if aerr, ok := err.(awserr.Error); ok { 601 switch aerr.Code() { 602 case ssmcontacts.ErrCodeAccessDeniedException: 603 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 604 case ssmcontacts.ErrCodeInternalServerException: 605 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 606 case ssmcontacts.ErrCodeThrottlingException: 607 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 608 case ssmcontacts.ErrCodeValidationException: 609 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 610 default: 611 fmt.Println(aerr.Error()) 612 } 613 } else { 614 // Print the error, cast err to awserr.Error to get the Code and 615 // Message from an error. 616 fmt.Println(err.Error()) 617 } 618 return 619 } 620 621 fmt.Println(result) 622 } 623 624 // To list all engagements 625 // 626 // The following list-engagements example lists engagements to escalation plans and 627 // contacts. You can also list engagements for a single incident. 628 func ExampleSSMContacts_ListEngagements_shared00() { 629 svc := ssmcontacts.New(session.New()) 630 input := &ssmcontacts.ListEngagementsInput{} 631 632 result, err := svc.ListEngagements(input) 633 if err != nil { 634 if aerr, ok := err.(awserr.Error); ok { 635 switch aerr.Code() { 636 case ssmcontacts.ErrCodeAccessDeniedException: 637 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 638 case ssmcontacts.ErrCodeInternalServerException: 639 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 640 case ssmcontacts.ErrCodeThrottlingException: 641 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 642 case ssmcontacts.ErrCodeValidationException: 643 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 644 default: 645 fmt.Println(aerr.Error()) 646 } 647 } else { 648 // Print the error, cast err to awserr.Error to get the Code and 649 // Message from an error. 650 fmt.Println(err.Error()) 651 } 652 return 653 } 654 655 fmt.Println(result) 656 } 657 658 // To list page receipts 659 // 660 // The following command-name example lists whether a page was received or not by a 661 // contact. 662 func ExampleSSMContacts_ListPageReceipts_shared00() { 663 svc := ssmcontacts.New(session.New()) 664 input := &ssmcontacts.ListPageReceiptsInput{ 665 PageId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:page/akuam/94ea0c7b-56d9-46c3-b84a-a37c8b067ad3"), 666 } 667 668 result, err := svc.ListPageReceipts(input) 669 if err != nil { 670 if aerr, ok := err.(awserr.Error); ok { 671 switch aerr.Code() { 672 case ssmcontacts.ErrCodeAccessDeniedException: 673 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 674 case ssmcontacts.ErrCodeInternalServerException: 675 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 676 case ssmcontacts.ErrCodeResourceNotFoundException: 677 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 678 case ssmcontacts.ErrCodeThrottlingException: 679 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 680 case ssmcontacts.ErrCodeValidationException: 681 fmt.Println(ssmcontacts.ErrCodeValidationException, 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 // To list pages by contact 697 // 698 // The following list-pages-by-contact example lists all pages to the specified contact. 699 func ExampleSSMContacts_ListPagesByContact_shared00() { 700 svc := ssmcontacts.New(session.New()) 701 input := &ssmcontacts.ListPagesByContactInput{ 702 ContactId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact/akuam"), 703 } 704 705 result, err := svc.ListPagesByContact(input) 706 if err != nil { 707 if aerr, ok := err.(awserr.Error); ok { 708 switch aerr.Code() { 709 case ssmcontacts.ErrCodeAccessDeniedException: 710 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 711 case ssmcontacts.ErrCodeInternalServerException: 712 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 713 case ssmcontacts.ErrCodeResourceNotFoundException: 714 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 715 case ssmcontacts.ErrCodeThrottlingException: 716 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 717 case ssmcontacts.ErrCodeValidationException: 718 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 719 default: 720 fmt.Println(aerr.Error()) 721 } 722 } else { 723 // Print the error, cast err to awserr.Error to get the Code and 724 // Message from an error. 725 fmt.Println(err.Error()) 726 } 727 return 728 } 729 730 fmt.Println(result) 731 } 732 733 // To list pages to contact channels started from an engagement. 734 // 735 // The following list-pages-by-engagement example lists the pages that occurred while 736 // engaging the defined engagement plan. 737 func ExampleSSMContacts_ListPagesByEngagement_shared00() { 738 svc := ssmcontacts.New(session.New()) 739 input := &ssmcontacts.ListPagesByEngagementInput{ 740 EngagementId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:engagement/akuam/78a29753-3674-4ac5-9f83-0468563567f0"), 741 } 742 743 result, err := svc.ListPagesByEngagement(input) 744 if err != nil { 745 if aerr, ok := err.(awserr.Error); ok { 746 switch aerr.Code() { 747 case ssmcontacts.ErrCodeAccessDeniedException: 748 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 749 case ssmcontacts.ErrCodeInternalServerException: 750 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 751 case ssmcontacts.ErrCodeResourceNotFoundException: 752 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 753 case ssmcontacts.ErrCodeThrottlingException: 754 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 755 case ssmcontacts.ErrCodeValidationException: 756 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 757 default: 758 fmt.Println(aerr.Error()) 759 } 760 } else { 761 // Print the error, cast err to awserr.Error to get the Code and 762 // Message from an error. 763 fmt.Println(err.Error()) 764 } 765 return 766 } 767 768 fmt.Println(result) 769 } 770 771 // To list tags for a contact 772 // 773 // The following list-tags-for-resource example lists the tags of the specified contact. 774 func ExampleSSMContacts_ListTagsForResource_shared00() { 775 svc := ssmcontacts.New(session.New()) 776 input := &ssmcontacts.ListTagsForResourceInput{ 777 ResourceARN: aws.String("arn:aws:ssm-contacts:us-east-1:111122223333:contact/akuam"), 778 } 779 780 result, err := svc.ListTagsForResource(input) 781 if err != nil { 782 if aerr, ok := err.(awserr.Error); ok { 783 switch aerr.Code() { 784 case ssmcontacts.ErrCodeAccessDeniedException: 785 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 786 case ssmcontacts.ErrCodeThrottlingException: 787 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 788 case ssmcontacts.ErrCodeResourceNotFoundException: 789 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 790 case ssmcontacts.ErrCodeValidationException: 791 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 792 case ssmcontacts.ErrCodeInternalServerException: 793 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 794 default: 795 fmt.Println(aerr.Error()) 796 } 797 } else { 798 // Print the error, cast err to awserr.Error to get the Code and 799 // Message from an error. 800 fmt.Println(err.Error()) 801 } 802 return 803 } 804 805 fmt.Println(result) 806 } 807 808 // To share a contact and engagements 809 // 810 // The following put-contact-policy example adds a resource policy to the contact Akua 811 // that shares the contact and related engagements with the principal. 812 func ExampleSSMContacts_PutContactPolicy_shared00() { 813 svc := ssmcontacts.New(session.New()) 814 input := &ssmcontacts.PutContactPolicyInput{ 815 ContactArn: aws.String("arn:aws:ssm-contacts:us-east-1:111122223333:contact/akuam"), 816 Policy: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"ExampleResourcePolicy\",\"Action\":[\"ssm-contacts:GetContact\",\"ssm-contacts:StartEngagement\",\"ssm-contacts:DescribeEngagement\",\"ssm-contacts:ListPagesByEngagement\",\"ssm-contacts:StopEngagement\"],\"Principal\":{\"AWS\":\"222233334444\"},\"Effect\":\"Allow\",\"Resource\":[\"arn:aws:ssm-contacts:*:111122223333:contact/akuam\",\"arn:aws:ssm-contacts:*:111122223333:engagement/akuam/*\"]}]}"), 817 } 818 819 result, err := svc.PutContactPolicy(input) 820 if err != nil { 821 if aerr, ok := err.(awserr.Error); ok { 822 switch aerr.Code() { 823 case ssmcontacts.ErrCodeAccessDeniedException: 824 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 825 case ssmcontacts.ErrCodeConflictException: 826 fmt.Println(ssmcontacts.ErrCodeConflictException, aerr.Error()) 827 case ssmcontacts.ErrCodeValidationException: 828 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 829 case ssmcontacts.ErrCodeResourceNotFoundException: 830 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 831 case ssmcontacts.ErrCodeThrottlingException: 832 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 833 case ssmcontacts.ErrCodeInternalServerException: 834 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 835 default: 836 fmt.Println(aerr.Error()) 837 } 838 } else { 839 // Print the error, cast err to awserr.Error to get the Code and 840 // Message from an error. 841 fmt.Println(err.Error()) 842 } 843 return 844 } 845 846 fmt.Println(result) 847 } 848 849 // To send an activation code 850 // 851 // The following send-activation-code example sends an activation code and message to 852 // the specified contact channel. 853 func ExampleSSMContacts_SendActivationCode_shared00() { 854 svc := ssmcontacts.New(session.New()) 855 input := &ssmcontacts.SendActivationCodeInput{ 856 ContactChannelId: aws.String("arn:aws:ssm-contacts:us-east-1:111122223333:contact-channel/akuam/8ddae2d1-12c8-4e45-b852-c8587266c400"), 857 } 858 859 result, err := svc.SendActivationCode(input) 860 if err != nil { 861 if aerr, ok := err.(awserr.Error); ok { 862 switch aerr.Code() { 863 case ssmcontacts.ErrCodeAccessDeniedException: 864 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 865 case ssmcontacts.ErrCodeDataEncryptionException: 866 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 867 case ssmcontacts.ErrCodeInternalServerException: 868 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 869 case ssmcontacts.ErrCodeResourceNotFoundException: 870 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 871 case ssmcontacts.ErrCodeServiceQuotaExceededException: 872 fmt.Println(ssmcontacts.ErrCodeServiceQuotaExceededException, aerr.Error()) 873 case ssmcontacts.ErrCodeThrottlingException: 874 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 875 case ssmcontacts.ErrCodeValidationException: 876 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 877 default: 878 fmt.Println(aerr.Error()) 879 } 880 } else { 881 // Print the error, cast err to awserr.Error to get the Code and 882 // Message from an error. 883 fmt.Println(err.Error()) 884 } 885 return 886 } 887 888 fmt.Println(result) 889 } 890 891 // Example 1: To page a contact's contact channels 892 // 893 // The following start-engagement pages contact's contact channels. Sender, subject, 894 // public-subject, and public-content are all free from fields. Incident Manager sends 895 // the subject and content to the provided VOICE or EMAIL contact channels. Incident 896 // Manager sends the public-subject and public-content to the provided SMS contact channels. 897 // Sender is used to track who started the engagement. 898 func ExampleSSMContacts_StartEngagement_shared00() { 899 svc := ssmcontacts.New(session.New()) 900 input := &ssmcontacts.StartEngagementInput{ 901 ContactId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact/akuam"), 902 Content: aws.String("Testing engagements"), 903 PublicContent: aws.String("Testing engagements"), 904 PublicSubject: aws.String("test"), 905 Sender: aws.String("tester"), 906 Subject: aws.String("test"), 907 } 908 909 result, err := svc.StartEngagement(input) 910 if err != nil { 911 if aerr, ok := err.(awserr.Error); ok { 912 switch aerr.Code() { 913 case ssmcontacts.ErrCodeAccessDeniedException: 914 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 915 case ssmcontacts.ErrCodeDataEncryptionException: 916 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 917 case ssmcontacts.ErrCodeInternalServerException: 918 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 919 case ssmcontacts.ErrCodeResourceNotFoundException: 920 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 921 case ssmcontacts.ErrCodeThrottlingException: 922 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 923 case ssmcontacts.ErrCodeValidationException: 924 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 925 default: 926 fmt.Println(aerr.Error()) 927 } 928 } else { 929 // Print the error, cast err to awserr.Error to get the Code and 930 // Message from an error. 931 fmt.Println(err.Error()) 932 } 933 return 934 } 935 936 fmt.Println(result) 937 } 938 939 // Example 2: To page a contact in the provided escalation plan. 940 // 941 // The following start-engagement engages contact's through an escalation plan. Each 942 // contact is paged according to their engagement plan. 943 func ExampleSSMContacts_StartEngagement_shared01() { 944 svc := ssmcontacts.New(session.New()) 945 input := &ssmcontacts.StartEngagementInput{ 946 ContactId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact/example_escalation"), 947 Content: aws.String("Testing engagements"), 948 PublicContent: aws.String("Testing engagements"), 949 PublicSubject: aws.String("test"), 950 Sender: aws.String("tester"), 951 Subject: aws.String("test"), 952 } 953 954 result, err := svc.StartEngagement(input) 955 if err != nil { 956 if aerr, ok := err.(awserr.Error); ok { 957 switch aerr.Code() { 958 case ssmcontacts.ErrCodeAccessDeniedException: 959 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 960 case ssmcontacts.ErrCodeDataEncryptionException: 961 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 962 case ssmcontacts.ErrCodeInternalServerException: 963 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 964 case ssmcontacts.ErrCodeResourceNotFoundException: 965 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 966 case ssmcontacts.ErrCodeThrottlingException: 967 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 968 case ssmcontacts.ErrCodeValidationException: 969 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 970 default: 971 fmt.Println(aerr.Error()) 972 } 973 } else { 974 // Print the error, cast err to awserr.Error to get the Code and 975 // Message from an error. 976 fmt.Println(err.Error()) 977 } 978 return 979 } 980 981 fmt.Println(result) 982 } 983 984 // To stop an engagement 985 // 986 // The following stop-engagement example stops an engagement from paging further contacts 987 // and contact channels. 988 func ExampleSSMContacts_StopEngagement_shared00() { 989 svc := ssmcontacts.New(session.New()) 990 input := &ssmcontacts.StopEngagementInput{ 991 EngagementId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:engagement/example_escalation/69e40ce1-8dbb-4d57-8962-5fbe7fc53356"), 992 } 993 994 result, err := svc.StopEngagement(input) 995 if err != nil { 996 if aerr, ok := err.(awserr.Error); ok { 997 switch aerr.Code() { 998 case ssmcontacts.ErrCodeAccessDeniedException: 999 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 1000 case ssmcontacts.ErrCodeValidationException: 1001 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 1002 case ssmcontacts.ErrCodeResourceNotFoundException: 1003 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 1004 case ssmcontacts.ErrCodeThrottlingException: 1005 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 1006 case ssmcontacts.ErrCodeInternalServerException: 1007 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 1008 default: 1009 fmt.Println(aerr.Error()) 1010 } 1011 } else { 1012 // Print the error, cast err to awserr.Error to get the Code and 1013 // Message from an error. 1014 fmt.Println(err.Error()) 1015 } 1016 return 1017 } 1018 1019 fmt.Println(result) 1020 } 1021 1022 // To tag a contact 1023 // 1024 // The following tag-resource example tags a specified contact with the provided tag 1025 // key value pair. 1026 func ExampleSSMContacts_TagResource_shared00() { 1027 svc := ssmcontacts.New(session.New()) 1028 input := &ssmcontacts.TagResourceInput{ 1029 ResourceARN: aws.String("arn:aws:ssm-contacts:us-east-1:111122223333:contact/akuam"), 1030 Tags: []*ssmcontacts.Tag{ 1031 { 1032 Key: aws.String("group1"), 1033 Value: aws.String("1"), 1034 }, 1035 }, 1036 } 1037 1038 result, err := svc.TagResource(input) 1039 if err != nil { 1040 if aerr, ok := err.(awserr.Error); ok { 1041 switch aerr.Code() { 1042 case ssmcontacts.ErrCodeAccessDeniedException: 1043 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 1044 case ssmcontacts.ErrCodeThrottlingException: 1045 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 1046 case ssmcontacts.ErrCodeResourceNotFoundException: 1047 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 1048 case ssmcontacts.ErrCodeInternalServerException: 1049 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 1050 case ssmcontacts.ErrCodeServiceQuotaExceededException: 1051 fmt.Println(ssmcontacts.ErrCodeServiceQuotaExceededException, aerr.Error()) 1052 case ssmcontacts.ErrCodeValidationException: 1053 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 1054 default: 1055 fmt.Println(aerr.Error()) 1056 } 1057 } else { 1058 // Print the error, cast err to awserr.Error to get the Code and 1059 // Message from an error. 1060 fmt.Println(err.Error()) 1061 } 1062 return 1063 } 1064 1065 fmt.Println(result) 1066 } 1067 1068 // To remove tags from a contact 1069 // 1070 // The following untag-resource example removes the group1 tag from the specified contact. 1071 func ExampleSSMContacts_UntagResource_shared00() { 1072 svc := ssmcontacts.New(session.New()) 1073 input := &ssmcontacts.UntagResourceInput{ 1074 ResourceARN: aws.String("arn:aws:ssm-contacts:us-east-1:111122223333:contact/akuam"), 1075 TagKeys: []*string{ 1076 aws.String("group1"), 1077 }, 1078 } 1079 1080 result, err := svc.UntagResource(input) 1081 if err != nil { 1082 if aerr, ok := err.(awserr.Error); ok { 1083 switch aerr.Code() { 1084 case ssmcontacts.ErrCodeAccessDeniedException: 1085 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 1086 case ssmcontacts.ErrCodeThrottlingException: 1087 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 1088 case ssmcontacts.ErrCodeResourceNotFoundException: 1089 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 1090 case ssmcontacts.ErrCodeValidationException: 1091 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 1092 case ssmcontacts.ErrCodeInternalServerException: 1093 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 1094 default: 1095 fmt.Println(aerr.Error()) 1096 } 1097 } else { 1098 // Print the error, cast err to awserr.Error to get the Code and 1099 // Message from an error. 1100 fmt.Println(err.Error()) 1101 } 1102 return 1103 } 1104 1105 fmt.Println(result) 1106 } 1107 1108 // To update the engagement plan of contact 1109 // 1110 // The following update-contact example updates the engagement plan of the contact Akua 1111 // to include the three types of contacts channels. This is done after creating contact 1112 // channels for Akua. 1113 func ExampleSSMContacts_UpdateContact_shared00() { 1114 svc := ssmcontacts.New(session.New()) 1115 input := &ssmcontacts.UpdateContactInput{ 1116 ContactId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact/akuam"), 1117 Plan: &ssmcontacts.Plan{ 1118 Stages: []*ssmcontacts.Stage{ 1119 { 1120 DurationInMinutes: aws.Int64(5), 1121 Targets: []*ssmcontacts.Target{ 1122 { 1123 ChannelTargetInfo: &ssmcontacts.ChannelTargetInfo{ 1124 ContactChannelId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact-channel/akuam/beb25840-5ac8-4644-95cc-7a8de390fa65"), 1125 RetryIntervalInMinutes: aws.Int64(1), 1126 }, 1127 }, 1128 }, 1129 }, 1130 { 1131 DurationInMinutes: aws.Int64(5), 1132 Targets: []*ssmcontacts.Target{ 1133 { 1134 ChannelTargetInfo: &ssmcontacts.ChannelTargetInfo{ 1135 ContactChannelId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact-channel/akuam/49f3c24d-5f9f-4638-ae25-3f49e04229ad"), 1136 RetryIntervalInMinutes: aws.Int64(1), 1137 }, 1138 }, 1139 }, 1140 }, 1141 { 1142 DurationInMinutes: aws.Int64(5), 1143 Targets: []*ssmcontacts.Target{ 1144 { 1145 ChannelTargetInfo: &ssmcontacts.ChannelTargetInfo{ 1146 ContactChannelId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact-channel/akuam/77d4f447-f619-4954-afff-85551e369c2a"), 1147 RetryIntervalInMinutes: aws.Int64(1), 1148 }, 1149 }, 1150 }, 1151 }, 1152 }, 1153 }, 1154 } 1155 1156 result, err := svc.UpdateContact(input) 1157 if err != nil { 1158 if aerr, ok := err.(awserr.Error); ok { 1159 switch aerr.Code() { 1160 case ssmcontacts.ErrCodeAccessDeniedException: 1161 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 1162 case ssmcontacts.ErrCodeInternalServerException: 1163 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 1164 case ssmcontacts.ErrCodeResourceNotFoundException: 1165 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 1166 case ssmcontacts.ErrCodeServiceQuotaExceededException: 1167 fmt.Println(ssmcontacts.ErrCodeServiceQuotaExceededException, aerr.Error()) 1168 case ssmcontacts.ErrCodeThrottlingException: 1169 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 1170 case ssmcontacts.ErrCodeValidationException: 1171 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 1172 case ssmcontacts.ErrCodeDataEncryptionException: 1173 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 1174 default: 1175 fmt.Println(aerr.Error()) 1176 } 1177 } else { 1178 // Print the error, cast err to awserr.Error to get the Code and 1179 // Message from an error. 1180 fmt.Println(err.Error()) 1181 } 1182 return 1183 } 1184 1185 fmt.Println(result) 1186 } 1187 1188 // To update a contact channel 1189 // 1190 // The following update-contact-channel example updates the name and delivery address 1191 // of a contact channel. 1192 func ExampleSSMContacts_UpdateContactChannel_shared00() { 1193 svc := ssmcontacts.New(session.New()) 1194 input := &ssmcontacts.UpdateContactChannelInput{ 1195 ContactChannelId: aws.String("arn:aws:ssm-contacts:us-east-2:111122223333:contact-channel/akuam/49f3c24d-5f9f-4638-ae25-3f49e04229ad"), 1196 DeliveryAddress: &ssmcontacts.ContactChannelAddress{ 1197 SimpleAddress: aws.String("+15005550198"), 1198 }, 1199 Name: aws.String("akuas voice channel"), 1200 } 1201 1202 result, err := svc.UpdateContactChannel(input) 1203 if err != nil { 1204 if aerr, ok := err.(awserr.Error); ok { 1205 switch aerr.Code() { 1206 case ssmcontacts.ErrCodeAccessDeniedException: 1207 fmt.Println(ssmcontacts.ErrCodeAccessDeniedException, aerr.Error()) 1208 case ssmcontacts.ErrCodeConflictException: 1209 fmt.Println(ssmcontacts.ErrCodeConflictException, aerr.Error()) 1210 case ssmcontacts.ErrCodeDataEncryptionException: 1211 fmt.Println(ssmcontacts.ErrCodeDataEncryptionException, aerr.Error()) 1212 case ssmcontacts.ErrCodeInternalServerException: 1213 fmt.Println(ssmcontacts.ErrCodeInternalServerException, aerr.Error()) 1214 case ssmcontacts.ErrCodeResourceNotFoundException: 1215 fmt.Println(ssmcontacts.ErrCodeResourceNotFoundException, aerr.Error()) 1216 case ssmcontacts.ErrCodeThrottlingException: 1217 fmt.Println(ssmcontacts.ErrCodeThrottlingException, aerr.Error()) 1218 case ssmcontacts.ErrCodeValidationException: 1219 fmt.Println(ssmcontacts.ErrCodeValidationException, aerr.Error()) 1220 default: 1221 fmt.Println(aerr.Error()) 1222 } 1223 } else { 1224 // Print the error, cast err to awserr.Error to get the Code and 1225 // Message from an error. 1226 fmt.Println(err.Error()) 1227 } 1228 return 1229 } 1230 1231 fmt.Println(result) 1232 }