github.com/aavshr/aws-sdk-go@v1.41.3/service/waf/examples_test.go (about) 1 // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 3 package waf_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/waf" 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 create an IP set 29 // 30 // The following example creates an IP match set named MyIPSetFriendlyName. 31 func ExampleWAF_CreateIPSet_shared00() { 32 svc := waf.New(session.New()) 33 input := &waf.CreateIPSetInput{ 34 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 35 Name: aws.String("MyIPSetFriendlyName"), 36 } 37 38 result, err := svc.CreateIPSet(input) 39 if err != nil { 40 if aerr, ok := err.(awserr.Error); ok { 41 switch aerr.Code() { 42 case waf.ErrCodeStaleDataException: 43 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 44 case waf.ErrCodeInternalErrorException: 45 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 46 case waf.ErrCodeInvalidAccountException: 47 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 48 case waf.ErrCodeDisallowedNameException: 49 fmt.Println(waf.ErrCodeDisallowedNameException, aerr.Error()) 50 case waf.ErrCodeInvalidParameterException: 51 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 52 case waf.ErrCodeLimitsExceededException: 53 fmt.Println(waf.ErrCodeLimitsExceededException, 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 // To create a rule 69 // 70 // The following example creates a rule named WAFByteHeaderRule. 71 func ExampleWAF_CreateRule_shared00() { 72 svc := waf.New(session.New()) 73 input := &waf.CreateRuleInput{ 74 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 75 MetricName: aws.String("WAFByteHeaderRule"), 76 Name: aws.String("WAFByteHeaderRule"), 77 } 78 79 result, err := svc.CreateRule(input) 80 if err != nil { 81 if aerr, ok := err.(awserr.Error); ok { 82 switch aerr.Code() { 83 case waf.ErrCodeStaleDataException: 84 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 85 case waf.ErrCodeInternalErrorException: 86 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 87 case waf.ErrCodeDisallowedNameException: 88 fmt.Println(waf.ErrCodeDisallowedNameException, aerr.Error()) 89 case waf.ErrCodeInvalidParameterException: 90 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 91 case waf.ErrCodeLimitsExceededException: 92 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 93 case waf.ErrCodeTagOperationException: 94 fmt.Println(waf.ErrCodeTagOperationException, aerr.Error()) 95 case waf.ErrCodeTagOperationInternalErrorException: 96 fmt.Println(waf.ErrCodeTagOperationInternalErrorException, aerr.Error()) 97 case waf.ErrCodeBadRequestException: 98 fmt.Println(waf.ErrCodeBadRequestException, aerr.Error()) 99 default: 100 fmt.Println(aerr.Error()) 101 } 102 } else { 103 // Print the error, cast err to awserr.Error to get the Code and 104 // Message from an error. 105 fmt.Println(err.Error()) 106 } 107 return 108 } 109 110 fmt.Println(result) 111 } 112 113 // To create a size constraint 114 // 115 // The following example creates size constraint set named MySampleSizeConstraintSet. 116 func ExampleWAF_CreateSizeConstraintSet_shared00() { 117 svc := waf.New(session.New()) 118 input := &waf.CreateSizeConstraintSetInput{ 119 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 120 Name: aws.String("MySampleSizeConstraintSet"), 121 } 122 123 result, err := svc.CreateSizeConstraintSet(input) 124 if err != nil { 125 if aerr, ok := err.(awserr.Error); ok { 126 switch aerr.Code() { 127 case waf.ErrCodeStaleDataException: 128 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 129 case waf.ErrCodeInternalErrorException: 130 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 131 case waf.ErrCodeInvalidAccountException: 132 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 133 case waf.ErrCodeDisallowedNameException: 134 fmt.Println(waf.ErrCodeDisallowedNameException, aerr.Error()) 135 case waf.ErrCodeInvalidParameterException: 136 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 137 case waf.ErrCodeLimitsExceededException: 138 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 139 default: 140 fmt.Println(aerr.Error()) 141 } 142 } else { 143 // Print the error, cast err to awserr.Error to get the Code and 144 // Message from an error. 145 fmt.Println(err.Error()) 146 } 147 return 148 } 149 150 fmt.Println(result) 151 } 152 153 // To create a SQL injection match set 154 // 155 // The following example creates a SQL injection match set named MySQLInjectionMatchSet. 156 func ExampleWAF_CreateSqlInjectionMatchSet_shared00() { 157 svc := waf.New(session.New()) 158 input := &waf.CreateSqlInjectionMatchSetInput{ 159 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 160 Name: aws.String("MySQLInjectionMatchSet"), 161 } 162 163 result, err := svc.CreateSqlInjectionMatchSet(input) 164 if err != nil { 165 if aerr, ok := err.(awserr.Error); ok { 166 switch aerr.Code() { 167 case waf.ErrCodeDisallowedNameException: 168 fmt.Println(waf.ErrCodeDisallowedNameException, aerr.Error()) 169 case waf.ErrCodeInternalErrorException: 170 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 171 case waf.ErrCodeInvalidAccountException: 172 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 173 case waf.ErrCodeInvalidParameterException: 174 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 175 case waf.ErrCodeStaleDataException: 176 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 177 case waf.ErrCodeLimitsExceededException: 178 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 179 default: 180 fmt.Println(aerr.Error()) 181 } 182 } else { 183 // Print the error, cast err to awserr.Error to get the Code and 184 // Message from an error. 185 fmt.Println(err.Error()) 186 } 187 return 188 } 189 190 fmt.Println(result) 191 } 192 193 // To create a web ACL 194 // 195 // The following example creates a web ACL named CreateExample. 196 func ExampleWAF_CreateWebACL_shared00() { 197 svc := waf.New(session.New()) 198 input := &waf.CreateWebACLInput{ 199 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 200 DefaultAction: &waf.WafAction{ 201 Type: aws.String("ALLOW"), 202 }, 203 MetricName: aws.String("CreateExample"), 204 Name: aws.String("CreateExample"), 205 } 206 207 result, err := svc.CreateWebACL(input) 208 if err != nil { 209 if aerr, ok := err.(awserr.Error); ok { 210 switch aerr.Code() { 211 case waf.ErrCodeStaleDataException: 212 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 213 case waf.ErrCodeInternalErrorException: 214 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 215 case waf.ErrCodeInvalidAccountException: 216 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 217 case waf.ErrCodeDisallowedNameException: 218 fmt.Println(waf.ErrCodeDisallowedNameException, aerr.Error()) 219 case waf.ErrCodeInvalidParameterException: 220 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 221 case waf.ErrCodeLimitsExceededException: 222 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 223 case waf.ErrCodeTagOperationException: 224 fmt.Println(waf.ErrCodeTagOperationException, aerr.Error()) 225 case waf.ErrCodeTagOperationInternalErrorException: 226 fmt.Println(waf.ErrCodeTagOperationInternalErrorException, aerr.Error()) 227 case waf.ErrCodeBadRequestException: 228 fmt.Println(waf.ErrCodeBadRequestException, aerr.Error()) 229 default: 230 fmt.Println(aerr.Error()) 231 } 232 } else { 233 // Print the error, cast err to awserr.Error to get the Code and 234 // Message from an error. 235 fmt.Println(err.Error()) 236 } 237 return 238 } 239 240 fmt.Println(result) 241 } 242 243 // To create an XSS match set 244 // 245 // The following example creates an XSS match set named MySampleXssMatchSet. 246 func ExampleWAF_CreateXssMatchSet_shared00() { 247 svc := waf.New(session.New()) 248 input := &waf.CreateXssMatchSetInput{ 249 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 250 Name: aws.String("MySampleXssMatchSet"), 251 } 252 253 result, err := svc.CreateXssMatchSet(input) 254 if err != nil { 255 if aerr, ok := err.(awserr.Error); ok { 256 switch aerr.Code() { 257 case waf.ErrCodeDisallowedNameException: 258 fmt.Println(waf.ErrCodeDisallowedNameException, aerr.Error()) 259 case waf.ErrCodeInternalErrorException: 260 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 261 case waf.ErrCodeInvalidAccountException: 262 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 263 case waf.ErrCodeInvalidParameterException: 264 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 265 case waf.ErrCodeStaleDataException: 266 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 267 case waf.ErrCodeLimitsExceededException: 268 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 269 default: 270 fmt.Println(aerr.Error()) 271 } 272 } else { 273 // Print the error, cast err to awserr.Error to get the Code and 274 // Message from an error. 275 fmt.Println(err.Error()) 276 } 277 return 278 } 279 280 fmt.Println(result) 281 } 282 283 // To delete a byte match set 284 // 285 // The following example deletes a byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5. 286 func ExampleWAF_DeleteByteMatchSet_shared00() { 287 svc := waf.New(session.New()) 288 input := &waf.DeleteByteMatchSetInput{ 289 ByteMatchSetId: aws.String("exampleIDs3t-46da-4fdb-b8d5-abc321j569j5"), 290 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 291 } 292 293 result, err := svc.DeleteByteMatchSet(input) 294 if err != nil { 295 if aerr, ok := err.(awserr.Error); ok { 296 switch aerr.Code() { 297 case waf.ErrCodeInternalErrorException: 298 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 299 case waf.ErrCodeInvalidAccountException: 300 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 301 case waf.ErrCodeNonexistentItemException: 302 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 303 case waf.ErrCodeReferencedItemException: 304 fmt.Println(waf.ErrCodeReferencedItemException, aerr.Error()) 305 case waf.ErrCodeStaleDataException: 306 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 307 case waf.ErrCodeNonEmptyEntityException: 308 fmt.Println(waf.ErrCodeNonEmptyEntityException, aerr.Error()) 309 default: 310 fmt.Println(aerr.Error()) 311 } 312 } else { 313 // Print the error, cast err to awserr.Error to get the Code and 314 // Message from an error. 315 fmt.Println(err.Error()) 316 } 317 return 318 } 319 320 fmt.Println(result) 321 } 322 323 // To delete an IP set 324 // 325 // The following example deletes an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 326 func ExampleWAF_DeleteIPSet_shared00() { 327 svc := waf.New(session.New()) 328 input := &waf.DeleteIPSetInput{ 329 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 330 IPSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 331 } 332 333 result, err := svc.DeleteIPSet(input) 334 if err != nil { 335 if aerr, ok := err.(awserr.Error); ok { 336 switch aerr.Code() { 337 case waf.ErrCodeStaleDataException: 338 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 339 case waf.ErrCodeInternalErrorException: 340 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 341 case waf.ErrCodeInvalidAccountException: 342 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 343 case waf.ErrCodeNonexistentItemException: 344 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 345 case waf.ErrCodeReferencedItemException: 346 fmt.Println(waf.ErrCodeReferencedItemException, aerr.Error()) 347 case waf.ErrCodeNonEmptyEntityException: 348 fmt.Println(waf.ErrCodeNonEmptyEntityException, aerr.Error()) 349 default: 350 fmt.Println(aerr.Error()) 351 } 352 } else { 353 // Print the error, cast err to awserr.Error to get the Code and 354 // Message from an error. 355 fmt.Println(err.Error()) 356 } 357 return 358 } 359 360 fmt.Println(result) 361 } 362 363 // To delete a rule 364 // 365 // The following example deletes a rule with the ID WAFRule-1-Example. 366 func ExampleWAF_DeleteRule_shared00() { 367 svc := waf.New(session.New()) 368 input := &waf.DeleteRuleInput{ 369 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 370 RuleId: aws.String("WAFRule-1-Example"), 371 } 372 373 result, err := svc.DeleteRule(input) 374 if err != nil { 375 if aerr, ok := err.(awserr.Error); ok { 376 switch aerr.Code() { 377 case waf.ErrCodeStaleDataException: 378 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 379 case waf.ErrCodeInternalErrorException: 380 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 381 case waf.ErrCodeInvalidAccountException: 382 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 383 case waf.ErrCodeNonexistentItemException: 384 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 385 case waf.ErrCodeReferencedItemException: 386 fmt.Println(waf.ErrCodeReferencedItemException, aerr.Error()) 387 case waf.ErrCodeNonEmptyEntityException: 388 fmt.Println(waf.ErrCodeNonEmptyEntityException, aerr.Error()) 389 case waf.ErrCodeTagOperationException: 390 fmt.Println(waf.ErrCodeTagOperationException, aerr.Error()) 391 case waf.ErrCodeTagOperationInternalErrorException: 392 fmt.Println(waf.ErrCodeTagOperationInternalErrorException, aerr.Error()) 393 default: 394 fmt.Println(aerr.Error()) 395 } 396 } else { 397 // Print the error, cast err to awserr.Error to get the Code and 398 // Message from an error. 399 fmt.Println(err.Error()) 400 } 401 return 402 } 403 404 fmt.Println(result) 405 } 406 407 // To delete a size constraint set 408 // 409 // The following example deletes a size constraint set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 410 func ExampleWAF_DeleteSizeConstraintSet_shared00() { 411 svc := waf.New(session.New()) 412 input := &waf.DeleteSizeConstraintSetInput{ 413 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 414 SizeConstraintSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 415 } 416 417 result, err := svc.DeleteSizeConstraintSet(input) 418 if err != nil { 419 if aerr, ok := err.(awserr.Error); ok { 420 switch aerr.Code() { 421 case waf.ErrCodeStaleDataException: 422 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 423 case waf.ErrCodeInternalErrorException: 424 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 425 case waf.ErrCodeInvalidAccountException: 426 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 427 case waf.ErrCodeNonexistentItemException: 428 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 429 case waf.ErrCodeReferencedItemException: 430 fmt.Println(waf.ErrCodeReferencedItemException, aerr.Error()) 431 case waf.ErrCodeNonEmptyEntityException: 432 fmt.Println(waf.ErrCodeNonEmptyEntityException, aerr.Error()) 433 default: 434 fmt.Println(aerr.Error()) 435 } 436 } else { 437 // Print the error, cast err to awserr.Error to get the Code and 438 // Message from an error. 439 fmt.Println(err.Error()) 440 } 441 return 442 } 443 444 fmt.Println(result) 445 } 446 447 // To delete a SQL injection match set 448 // 449 // The following example deletes a SQL injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 450 func ExampleWAF_DeleteSqlInjectionMatchSet_shared00() { 451 svc := waf.New(session.New()) 452 input := &waf.DeleteSqlInjectionMatchSetInput{ 453 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 454 SqlInjectionMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 455 } 456 457 result, err := svc.DeleteSqlInjectionMatchSet(input) 458 if err != nil { 459 if aerr, ok := err.(awserr.Error); ok { 460 switch aerr.Code() { 461 case waf.ErrCodeInternalErrorException: 462 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 463 case waf.ErrCodeInvalidAccountException: 464 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 465 case waf.ErrCodeNonexistentItemException: 466 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 467 case waf.ErrCodeReferencedItemException: 468 fmt.Println(waf.ErrCodeReferencedItemException, aerr.Error()) 469 case waf.ErrCodeStaleDataException: 470 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 471 case waf.ErrCodeNonEmptyEntityException: 472 fmt.Println(waf.ErrCodeNonEmptyEntityException, aerr.Error()) 473 default: 474 fmt.Println(aerr.Error()) 475 } 476 } else { 477 // Print the error, cast err to awserr.Error to get the Code and 478 // Message from an error. 479 fmt.Println(err.Error()) 480 } 481 return 482 } 483 484 fmt.Println(result) 485 } 486 487 // To delete a web ACL 488 // 489 // The following example deletes a web ACL with the ID example-46da-4444-5555-example. 490 func ExampleWAF_DeleteWebACL_shared00() { 491 svc := waf.New(session.New()) 492 input := &waf.DeleteWebACLInput{ 493 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 494 WebACLId: aws.String("example-46da-4444-5555-example"), 495 } 496 497 result, err := svc.DeleteWebACL(input) 498 if err != nil { 499 if aerr, ok := err.(awserr.Error); ok { 500 switch aerr.Code() { 501 case waf.ErrCodeStaleDataException: 502 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 503 case waf.ErrCodeInternalErrorException: 504 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 505 case waf.ErrCodeInvalidAccountException: 506 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 507 case waf.ErrCodeNonexistentItemException: 508 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 509 case waf.ErrCodeReferencedItemException: 510 fmt.Println(waf.ErrCodeReferencedItemException, aerr.Error()) 511 case waf.ErrCodeNonEmptyEntityException: 512 fmt.Println(waf.ErrCodeNonEmptyEntityException, aerr.Error()) 513 case waf.ErrCodeTagOperationException: 514 fmt.Println(waf.ErrCodeTagOperationException, aerr.Error()) 515 case waf.ErrCodeTagOperationInternalErrorException: 516 fmt.Println(waf.ErrCodeTagOperationInternalErrorException, aerr.Error()) 517 default: 518 fmt.Println(aerr.Error()) 519 } 520 } else { 521 // Print the error, cast err to awserr.Error to get the Code and 522 // Message from an error. 523 fmt.Println(err.Error()) 524 } 525 return 526 } 527 528 fmt.Println(result) 529 } 530 531 // To delete an XSS match set 532 // 533 // The following example deletes an XSS match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 534 func ExampleWAF_DeleteXssMatchSet_shared00() { 535 svc := waf.New(session.New()) 536 input := &waf.DeleteXssMatchSetInput{ 537 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 538 XssMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 539 } 540 541 result, err := svc.DeleteXssMatchSet(input) 542 if err != nil { 543 if aerr, ok := err.(awserr.Error); ok { 544 switch aerr.Code() { 545 case waf.ErrCodeInternalErrorException: 546 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 547 case waf.ErrCodeInvalidAccountException: 548 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 549 case waf.ErrCodeNonexistentItemException: 550 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 551 case waf.ErrCodeReferencedItemException: 552 fmt.Println(waf.ErrCodeReferencedItemException, aerr.Error()) 553 case waf.ErrCodeStaleDataException: 554 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 555 case waf.ErrCodeNonEmptyEntityException: 556 fmt.Println(waf.ErrCodeNonEmptyEntityException, aerr.Error()) 557 default: 558 fmt.Println(aerr.Error()) 559 } 560 } else { 561 // Print the error, cast err to awserr.Error to get the Code and 562 // Message from an error. 563 fmt.Println(err.Error()) 564 } 565 return 566 } 567 568 fmt.Println(result) 569 } 570 571 // To get a byte match set 572 // 573 // The following example returns the details of a byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5. 574 func ExampleWAF_GetByteMatchSet_shared00() { 575 svc := waf.New(session.New()) 576 input := &waf.GetByteMatchSetInput{ 577 ByteMatchSetId: aws.String("exampleIDs3t-46da-4fdb-b8d5-abc321j569j5"), 578 } 579 580 result, err := svc.GetByteMatchSet(input) 581 if err != nil { 582 if aerr, ok := err.(awserr.Error); ok { 583 switch aerr.Code() { 584 case waf.ErrCodeInternalErrorException: 585 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 586 case waf.ErrCodeInvalidAccountException: 587 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 588 case waf.ErrCodeNonexistentItemException: 589 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 590 default: 591 fmt.Println(aerr.Error()) 592 } 593 } else { 594 // Print the error, cast err to awserr.Error to get the Code and 595 // Message from an error. 596 fmt.Println(err.Error()) 597 } 598 return 599 } 600 601 fmt.Println(result) 602 } 603 604 // To get a change token 605 // 606 // The following example returns a change token to use for a create, update or delete 607 // operation. 608 func ExampleWAF_GetChangeToken_shared00() { 609 svc := waf.New(session.New()) 610 input := &waf.GetChangeTokenInput{} 611 612 result, err := svc.GetChangeToken(input) 613 if err != nil { 614 if aerr, ok := err.(awserr.Error); ok { 615 switch aerr.Code() { 616 case waf.ErrCodeInternalErrorException: 617 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 618 default: 619 fmt.Println(aerr.Error()) 620 } 621 } else { 622 // Print the error, cast err to awserr.Error to get the Code and 623 // Message from an error. 624 fmt.Println(err.Error()) 625 } 626 return 627 } 628 629 fmt.Println(result) 630 } 631 632 // To get the change token status 633 // 634 // The following example returns the status of a change token with the ID abcd12f2-46da-4fdb-b8d5-fbd4c466928f. 635 func ExampleWAF_GetChangeTokenStatus_shared00() { 636 svc := waf.New(session.New()) 637 input := &waf.GetChangeTokenStatusInput{ 638 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 639 } 640 641 result, err := svc.GetChangeTokenStatus(input) 642 if err != nil { 643 if aerr, ok := err.(awserr.Error); ok { 644 switch aerr.Code() { 645 case waf.ErrCodeNonexistentItemException: 646 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 647 case waf.ErrCodeInternalErrorException: 648 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 649 default: 650 fmt.Println(aerr.Error()) 651 } 652 } else { 653 // Print the error, cast err to awserr.Error to get the Code and 654 // Message from an error. 655 fmt.Println(err.Error()) 656 } 657 return 658 } 659 660 fmt.Println(result) 661 } 662 663 // To get an IP set 664 // 665 // The following example returns the details of an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 666 func ExampleWAF_GetIPSet_shared00() { 667 svc := waf.New(session.New()) 668 input := &waf.GetIPSetInput{ 669 IPSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 670 } 671 672 result, err := svc.GetIPSet(input) 673 if err != nil { 674 if aerr, ok := err.(awserr.Error); ok { 675 switch aerr.Code() { 676 case waf.ErrCodeInternalErrorException: 677 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 678 case waf.ErrCodeInvalidAccountException: 679 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 680 case waf.ErrCodeNonexistentItemException: 681 fmt.Println(waf.ErrCodeNonexistentItemException, 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 get a rule 697 // 698 // The following example returns the details of a rule with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 699 func ExampleWAF_GetRule_shared00() { 700 svc := waf.New(session.New()) 701 input := &waf.GetRuleInput{ 702 RuleId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 703 } 704 705 result, err := svc.GetRule(input) 706 if err != nil { 707 if aerr, ok := err.(awserr.Error); ok { 708 switch aerr.Code() { 709 case waf.ErrCodeInternalErrorException: 710 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 711 case waf.ErrCodeInvalidAccountException: 712 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 713 case waf.ErrCodeNonexistentItemException: 714 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 715 default: 716 fmt.Println(aerr.Error()) 717 } 718 } else { 719 // Print the error, cast err to awserr.Error to get the Code and 720 // Message from an error. 721 fmt.Println(err.Error()) 722 } 723 return 724 } 725 726 fmt.Println(result) 727 } 728 729 // To get a sampled requests 730 // 731 // The following example returns detailed information about 100 requests --a sample-- 732 // that AWS WAF randomly selects from among the first 5,000 requests that your AWS resource 733 // received between the time period 2016-09-27T15:50Z to 2016-09-27T15:50Z. 734 func ExampleWAF_GetSampledRequests_shared00() { 735 svc := waf.New(session.New()) 736 input := &waf.GetSampledRequestsInput{ 737 MaxItems: aws.Int64(100), 738 RuleId: aws.String("WAFRule-1-Example"), 739 TimeWindow: &waf.TimeWindow{ 740 EndTime: parseTime("2006-01-02T15:04:05.999999999Z", "2016-09-27T15:50Z"), 741 StartTime: parseTime("2006-01-02T15:04:05.999999999Z", "2016-09-27T15:50Z"), 742 }, 743 WebAclId: aws.String("createwebacl-1472061481310"), 744 } 745 746 result, err := svc.GetSampledRequests(input) 747 if err != nil { 748 if aerr, ok := err.(awserr.Error); ok { 749 switch aerr.Code() { 750 case waf.ErrCodeNonexistentItemException: 751 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 752 case waf.ErrCodeInternalErrorException: 753 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 754 default: 755 fmt.Println(aerr.Error()) 756 } 757 } else { 758 // Print the error, cast err to awserr.Error to get the Code and 759 // Message from an error. 760 fmt.Println(err.Error()) 761 } 762 return 763 } 764 765 fmt.Println(result) 766 } 767 768 // To get a size constraint set 769 // 770 // The following example returns the details of a size constraint match set with the 771 // ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 772 func ExampleWAF_GetSizeConstraintSet_shared00() { 773 svc := waf.New(session.New()) 774 input := &waf.GetSizeConstraintSetInput{ 775 SizeConstraintSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 776 } 777 778 result, err := svc.GetSizeConstraintSet(input) 779 if err != nil { 780 if aerr, ok := err.(awserr.Error); ok { 781 switch aerr.Code() { 782 case waf.ErrCodeInternalErrorException: 783 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 784 case waf.ErrCodeInvalidAccountException: 785 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 786 case waf.ErrCodeNonexistentItemException: 787 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 788 default: 789 fmt.Println(aerr.Error()) 790 } 791 } else { 792 // Print the error, cast err to awserr.Error to get the Code and 793 // Message from an error. 794 fmt.Println(err.Error()) 795 } 796 return 797 } 798 799 fmt.Println(result) 800 } 801 802 // To get a SQL injection match set 803 // 804 // The following example returns the details of a SQL injection match set with the ID 805 // example1ds3t-46da-4fdb-b8d5-abc321j569j5. 806 func ExampleWAF_GetSqlInjectionMatchSet_shared00() { 807 svc := waf.New(session.New()) 808 input := &waf.GetSqlInjectionMatchSetInput{ 809 SqlInjectionMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 810 } 811 812 result, err := svc.GetSqlInjectionMatchSet(input) 813 if err != nil { 814 if aerr, ok := err.(awserr.Error); ok { 815 switch aerr.Code() { 816 case waf.ErrCodeInternalErrorException: 817 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 818 case waf.ErrCodeInvalidAccountException: 819 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 820 case waf.ErrCodeNonexistentItemException: 821 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 822 default: 823 fmt.Println(aerr.Error()) 824 } 825 } else { 826 // Print the error, cast err to awserr.Error to get the Code and 827 // Message from an error. 828 fmt.Println(err.Error()) 829 } 830 return 831 } 832 833 fmt.Println(result) 834 } 835 836 // To get a web ACL 837 // 838 // The following example returns the details of a web ACL with the ID createwebacl-1472061481310. 839 func ExampleWAF_GetWebACL_shared00() { 840 svc := waf.New(session.New()) 841 input := &waf.GetWebACLInput{ 842 WebACLId: aws.String("createwebacl-1472061481310"), 843 } 844 845 result, err := svc.GetWebACL(input) 846 if err != nil { 847 if aerr, ok := err.(awserr.Error); ok { 848 switch aerr.Code() { 849 case waf.ErrCodeInternalErrorException: 850 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 851 case waf.ErrCodeInvalidAccountException: 852 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 853 case waf.ErrCodeNonexistentItemException: 854 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 855 default: 856 fmt.Println(aerr.Error()) 857 } 858 } else { 859 // Print the error, cast err to awserr.Error to get the Code and 860 // Message from an error. 861 fmt.Println(err.Error()) 862 } 863 return 864 } 865 866 fmt.Println(result) 867 } 868 869 // To get an XSS match set 870 // 871 // The following example returns the details of an XSS match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 872 func ExampleWAF_GetXssMatchSet_shared00() { 873 svc := waf.New(session.New()) 874 input := &waf.GetXssMatchSetInput{ 875 XssMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 876 } 877 878 result, err := svc.GetXssMatchSet(input) 879 if err != nil { 880 if aerr, ok := err.(awserr.Error); ok { 881 switch aerr.Code() { 882 case waf.ErrCodeInternalErrorException: 883 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 884 case waf.ErrCodeInvalidAccountException: 885 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 886 case waf.ErrCodeNonexistentItemException: 887 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 888 default: 889 fmt.Println(aerr.Error()) 890 } 891 } else { 892 // Print the error, cast err to awserr.Error to get the Code and 893 // Message from an error. 894 fmt.Println(err.Error()) 895 } 896 return 897 } 898 899 fmt.Println(result) 900 } 901 902 // To list IP sets 903 // 904 // The following example returns an array of up to 100 IP match sets. 905 func ExampleWAF_ListIPSets_shared00() { 906 svc := waf.New(session.New()) 907 input := &waf.ListIPSetsInput{ 908 Limit: aws.Int64(100), 909 } 910 911 result, err := svc.ListIPSets(input) 912 if err != nil { 913 if aerr, ok := err.(awserr.Error); ok { 914 switch aerr.Code() { 915 case waf.ErrCodeInternalErrorException: 916 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 917 case waf.ErrCodeInvalidAccountException: 918 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 919 default: 920 fmt.Println(aerr.Error()) 921 } 922 } else { 923 // Print the error, cast err to awserr.Error to get the Code and 924 // Message from an error. 925 fmt.Println(err.Error()) 926 } 927 return 928 } 929 930 fmt.Println(result) 931 } 932 933 // To list rules 934 // 935 // The following example returns an array of up to 100 rules. 936 func ExampleWAF_ListRules_shared00() { 937 svc := waf.New(session.New()) 938 input := &waf.ListRulesInput{ 939 Limit: aws.Int64(100), 940 } 941 942 result, err := svc.ListRules(input) 943 if err != nil { 944 if aerr, ok := err.(awserr.Error); ok { 945 switch aerr.Code() { 946 case waf.ErrCodeInternalErrorException: 947 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 948 case waf.ErrCodeInvalidAccountException: 949 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 950 default: 951 fmt.Println(aerr.Error()) 952 } 953 } else { 954 // Print the error, cast err to awserr.Error to get the Code and 955 // Message from an error. 956 fmt.Println(err.Error()) 957 } 958 return 959 } 960 961 fmt.Println(result) 962 } 963 964 // To list a size constraint sets 965 // 966 // The following example returns an array of up to 100 size contraint match sets. 967 func ExampleWAF_ListSizeConstraintSets_shared00() { 968 svc := waf.New(session.New()) 969 input := &waf.ListSizeConstraintSetsInput{ 970 Limit: aws.Int64(100), 971 } 972 973 result, err := svc.ListSizeConstraintSets(input) 974 if err != nil { 975 if aerr, ok := err.(awserr.Error); ok { 976 switch aerr.Code() { 977 case waf.ErrCodeInternalErrorException: 978 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 979 case waf.ErrCodeInvalidAccountException: 980 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 981 default: 982 fmt.Println(aerr.Error()) 983 } 984 } else { 985 // Print the error, cast err to awserr.Error to get the Code and 986 // Message from an error. 987 fmt.Println(err.Error()) 988 } 989 return 990 } 991 992 fmt.Println(result) 993 } 994 995 // To list SQL injection match sets 996 // 997 // The following example returns an array of up to 100 SQL injection match sets. 998 func ExampleWAF_ListSqlInjectionMatchSets_shared00() { 999 svc := waf.New(session.New()) 1000 input := &waf.ListSqlInjectionMatchSetsInput{ 1001 Limit: aws.Int64(100), 1002 } 1003 1004 result, err := svc.ListSqlInjectionMatchSets(input) 1005 if err != nil { 1006 if aerr, ok := err.(awserr.Error); ok { 1007 switch aerr.Code() { 1008 case waf.ErrCodeInternalErrorException: 1009 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 1010 case waf.ErrCodeInvalidAccountException: 1011 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 1012 default: 1013 fmt.Println(aerr.Error()) 1014 } 1015 } else { 1016 // Print the error, cast err to awserr.Error to get the Code and 1017 // Message from an error. 1018 fmt.Println(err.Error()) 1019 } 1020 return 1021 } 1022 1023 fmt.Println(result) 1024 } 1025 1026 // To list Web ACLs 1027 // 1028 // The following example returns an array of up to 100 web ACLs. 1029 func ExampleWAF_ListWebACLs_shared00() { 1030 svc := waf.New(session.New()) 1031 input := &waf.ListWebACLsInput{ 1032 Limit: aws.Int64(100), 1033 } 1034 1035 result, err := svc.ListWebACLs(input) 1036 if err != nil { 1037 if aerr, ok := err.(awserr.Error); ok { 1038 switch aerr.Code() { 1039 case waf.ErrCodeInternalErrorException: 1040 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 1041 case waf.ErrCodeInvalidAccountException: 1042 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 1043 default: 1044 fmt.Println(aerr.Error()) 1045 } 1046 } else { 1047 // Print the error, cast err to awserr.Error to get the Code and 1048 // Message from an error. 1049 fmt.Println(err.Error()) 1050 } 1051 return 1052 } 1053 1054 fmt.Println(result) 1055 } 1056 1057 // To list XSS match sets 1058 // 1059 // The following example returns an array of up to 100 XSS match sets. 1060 func ExampleWAF_ListXssMatchSets_shared00() { 1061 svc := waf.New(session.New()) 1062 input := &waf.ListXssMatchSetsInput{ 1063 Limit: aws.Int64(100), 1064 } 1065 1066 result, err := svc.ListXssMatchSets(input) 1067 if err != nil { 1068 if aerr, ok := err.(awserr.Error); ok { 1069 switch aerr.Code() { 1070 case waf.ErrCodeInternalErrorException: 1071 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 1072 case waf.ErrCodeInvalidAccountException: 1073 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 1074 default: 1075 fmt.Println(aerr.Error()) 1076 } 1077 } else { 1078 // Print the error, cast err to awserr.Error to get the Code and 1079 // Message from an error. 1080 fmt.Println(err.Error()) 1081 } 1082 return 1083 } 1084 1085 fmt.Println(result) 1086 } 1087 1088 // To update a byte match set 1089 // 1090 // The following example deletes a ByteMatchTuple object (filters) in an byte match 1091 // set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5. 1092 func ExampleWAF_UpdateByteMatchSet_shared00() { 1093 svc := waf.New(session.New()) 1094 input := &waf.UpdateByteMatchSetInput{ 1095 ByteMatchSetId: aws.String("exampleIDs3t-46da-4fdb-b8d5-abc321j569j5"), 1096 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 1097 Updates: []*waf.ByteMatchSetUpdate{ 1098 { 1099 Action: aws.String("DELETE"), 1100 ByteMatchTuple: &waf.ByteMatchTuple{ 1101 FieldToMatch: &waf.FieldToMatch{ 1102 Data: aws.String("referer"), 1103 Type: aws.String("HEADER"), 1104 }, 1105 PositionalConstraint: aws.String("CONTAINS"), 1106 TargetString: []byte("badrefer1"), 1107 TextTransformation: aws.String("NONE"), 1108 }, 1109 }, 1110 }, 1111 } 1112 1113 result, err := svc.UpdateByteMatchSet(input) 1114 if err != nil { 1115 if aerr, ok := err.(awserr.Error); ok { 1116 switch aerr.Code() { 1117 case waf.ErrCodeInternalErrorException: 1118 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 1119 case waf.ErrCodeInvalidAccountException: 1120 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 1121 case waf.ErrCodeInvalidOperationException: 1122 fmt.Println(waf.ErrCodeInvalidOperationException, aerr.Error()) 1123 case waf.ErrCodeInvalidParameterException: 1124 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 1125 case waf.ErrCodeNonexistentContainerException: 1126 fmt.Println(waf.ErrCodeNonexistentContainerException, aerr.Error()) 1127 case waf.ErrCodeNonexistentItemException: 1128 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 1129 case waf.ErrCodeStaleDataException: 1130 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 1131 case waf.ErrCodeLimitsExceededException: 1132 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 1133 default: 1134 fmt.Println(aerr.Error()) 1135 } 1136 } else { 1137 // Print the error, cast err to awserr.Error to get the Code and 1138 // Message from an error. 1139 fmt.Println(err.Error()) 1140 } 1141 return 1142 } 1143 1144 fmt.Println(result) 1145 } 1146 1147 // To update an IP set 1148 // 1149 // The following example deletes an IPSetDescriptor object in an IP match set with the 1150 // ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 1151 func ExampleWAF_UpdateIPSet_shared00() { 1152 svc := waf.New(session.New()) 1153 input := &waf.UpdateIPSetInput{ 1154 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 1155 IPSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 1156 Updates: []*waf.IPSetUpdate{ 1157 { 1158 Action: aws.String("DELETE"), 1159 IPSetDescriptor: &waf.IPSetDescriptor{ 1160 Type: aws.String("IPV4"), 1161 Value: aws.String("192.0.2.44/32"), 1162 }, 1163 }, 1164 }, 1165 } 1166 1167 result, err := svc.UpdateIPSet(input) 1168 if err != nil { 1169 if aerr, ok := err.(awserr.Error); ok { 1170 switch aerr.Code() { 1171 case waf.ErrCodeStaleDataException: 1172 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 1173 case waf.ErrCodeInternalErrorException: 1174 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 1175 case waf.ErrCodeInvalidAccountException: 1176 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 1177 case waf.ErrCodeInvalidOperationException: 1178 fmt.Println(waf.ErrCodeInvalidOperationException, aerr.Error()) 1179 case waf.ErrCodeInvalidParameterException: 1180 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 1181 case waf.ErrCodeNonexistentContainerException: 1182 fmt.Println(waf.ErrCodeNonexistentContainerException, aerr.Error()) 1183 case waf.ErrCodeNonexistentItemException: 1184 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 1185 case waf.ErrCodeReferencedItemException: 1186 fmt.Println(waf.ErrCodeReferencedItemException, aerr.Error()) 1187 case waf.ErrCodeLimitsExceededException: 1188 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 1189 default: 1190 fmt.Println(aerr.Error()) 1191 } 1192 } else { 1193 // Print the error, cast err to awserr.Error to get the Code and 1194 // Message from an error. 1195 fmt.Println(err.Error()) 1196 } 1197 return 1198 } 1199 1200 fmt.Println(result) 1201 } 1202 1203 // To update a rule 1204 // 1205 // The following example deletes a Predicate object in a rule with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 1206 func ExampleWAF_UpdateRule_shared00() { 1207 svc := waf.New(session.New()) 1208 input := &waf.UpdateRuleInput{ 1209 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 1210 RuleId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 1211 Updates: []*waf.RuleUpdate{ 1212 { 1213 Action: aws.String("DELETE"), 1214 Predicate: &waf.Predicate{ 1215 DataId: aws.String("MyByteMatchSetID"), 1216 Negated: aws.Bool(false), 1217 Type: aws.String("ByteMatch"), 1218 }, 1219 }, 1220 }, 1221 } 1222 1223 result, err := svc.UpdateRule(input) 1224 if err != nil { 1225 if aerr, ok := err.(awserr.Error); ok { 1226 switch aerr.Code() { 1227 case waf.ErrCodeStaleDataException: 1228 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 1229 case waf.ErrCodeInternalErrorException: 1230 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 1231 case waf.ErrCodeInvalidAccountException: 1232 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 1233 case waf.ErrCodeInvalidOperationException: 1234 fmt.Println(waf.ErrCodeInvalidOperationException, aerr.Error()) 1235 case waf.ErrCodeInvalidParameterException: 1236 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 1237 case waf.ErrCodeNonexistentContainerException: 1238 fmt.Println(waf.ErrCodeNonexistentContainerException, aerr.Error()) 1239 case waf.ErrCodeNonexistentItemException: 1240 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 1241 case waf.ErrCodeReferencedItemException: 1242 fmt.Println(waf.ErrCodeReferencedItemException, aerr.Error()) 1243 case waf.ErrCodeLimitsExceededException: 1244 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 1245 default: 1246 fmt.Println(aerr.Error()) 1247 } 1248 } else { 1249 // Print the error, cast err to awserr.Error to get the Code and 1250 // Message from an error. 1251 fmt.Println(err.Error()) 1252 } 1253 return 1254 } 1255 1256 fmt.Println(result) 1257 } 1258 1259 // To update a size constraint set 1260 // 1261 // The following example deletes a SizeConstraint object (filters) in a size constraint 1262 // set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 1263 func ExampleWAF_UpdateSizeConstraintSet_shared00() { 1264 svc := waf.New(session.New()) 1265 input := &waf.UpdateSizeConstraintSetInput{ 1266 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 1267 SizeConstraintSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 1268 Updates: []*waf.SizeConstraintSetUpdate{ 1269 { 1270 Action: aws.String("DELETE"), 1271 SizeConstraint: &waf.SizeConstraint{ 1272 ComparisonOperator: aws.String("GT"), 1273 FieldToMatch: &waf.FieldToMatch{ 1274 Type: aws.String("QUERY_STRING"), 1275 }, 1276 Size: aws.Int64(0), 1277 TextTransformation: aws.String("NONE"), 1278 }, 1279 }, 1280 }, 1281 } 1282 1283 result, err := svc.UpdateSizeConstraintSet(input) 1284 if err != nil { 1285 if aerr, ok := err.(awserr.Error); ok { 1286 switch aerr.Code() { 1287 case waf.ErrCodeStaleDataException: 1288 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 1289 case waf.ErrCodeInternalErrorException: 1290 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 1291 case waf.ErrCodeInvalidAccountException: 1292 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 1293 case waf.ErrCodeInvalidOperationException: 1294 fmt.Println(waf.ErrCodeInvalidOperationException, aerr.Error()) 1295 case waf.ErrCodeInvalidParameterException: 1296 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 1297 case waf.ErrCodeNonexistentContainerException: 1298 fmt.Println(waf.ErrCodeNonexistentContainerException, aerr.Error()) 1299 case waf.ErrCodeNonexistentItemException: 1300 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 1301 case waf.ErrCodeReferencedItemException: 1302 fmt.Println(waf.ErrCodeReferencedItemException, aerr.Error()) 1303 case waf.ErrCodeLimitsExceededException: 1304 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 1305 default: 1306 fmt.Println(aerr.Error()) 1307 } 1308 } else { 1309 // Print the error, cast err to awserr.Error to get the Code and 1310 // Message from an error. 1311 fmt.Println(err.Error()) 1312 } 1313 return 1314 } 1315 1316 fmt.Println(result) 1317 } 1318 1319 // To update a SQL injection match set 1320 // 1321 // The following example deletes a SqlInjectionMatchTuple object (filters) in a SQL 1322 // injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 1323 func ExampleWAF_UpdateSqlInjectionMatchSet_shared00() { 1324 svc := waf.New(session.New()) 1325 input := &waf.UpdateSqlInjectionMatchSetInput{ 1326 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 1327 SqlInjectionMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 1328 Updates: []*waf.SqlInjectionMatchSetUpdate{ 1329 { 1330 Action: aws.String("DELETE"), 1331 SqlInjectionMatchTuple: &waf.SqlInjectionMatchTuple{ 1332 FieldToMatch: &waf.FieldToMatch{ 1333 Type: aws.String("QUERY_STRING"), 1334 }, 1335 TextTransformation: aws.String("URL_DECODE"), 1336 }, 1337 }, 1338 }, 1339 } 1340 1341 result, err := svc.UpdateSqlInjectionMatchSet(input) 1342 if err != nil { 1343 if aerr, ok := err.(awserr.Error); ok { 1344 switch aerr.Code() { 1345 case waf.ErrCodeInternalErrorException: 1346 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 1347 case waf.ErrCodeInvalidAccountException: 1348 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 1349 case waf.ErrCodeInvalidOperationException: 1350 fmt.Println(waf.ErrCodeInvalidOperationException, aerr.Error()) 1351 case waf.ErrCodeInvalidParameterException: 1352 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 1353 case waf.ErrCodeNonexistentContainerException: 1354 fmt.Println(waf.ErrCodeNonexistentContainerException, aerr.Error()) 1355 case waf.ErrCodeNonexistentItemException: 1356 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 1357 case waf.ErrCodeStaleDataException: 1358 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 1359 case waf.ErrCodeLimitsExceededException: 1360 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 1361 default: 1362 fmt.Println(aerr.Error()) 1363 } 1364 } else { 1365 // Print the error, cast err to awserr.Error to get the Code and 1366 // Message from an error. 1367 fmt.Println(err.Error()) 1368 } 1369 return 1370 } 1371 1372 fmt.Println(result) 1373 } 1374 1375 // To update a Web ACL 1376 // 1377 // The following example deletes an ActivatedRule object in a WebACL with the ID webacl-1472061481310. 1378 func ExampleWAF_UpdateWebACL_shared00() { 1379 svc := waf.New(session.New()) 1380 input := &waf.UpdateWebACLInput{ 1381 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 1382 DefaultAction: &waf.WafAction{ 1383 Type: aws.String("ALLOW"), 1384 }, 1385 Updates: []*waf.WebACLUpdate{ 1386 { 1387 Action: aws.String("DELETE"), 1388 ActivatedRule: &waf.ActivatedRule{ 1389 Action: &waf.WafAction{ 1390 Type: aws.String("ALLOW"), 1391 }, 1392 Priority: aws.Int64(1), 1393 RuleId: aws.String("WAFRule-1-Example"), 1394 }, 1395 }, 1396 }, 1397 WebACLId: aws.String("webacl-1472061481310"), 1398 } 1399 1400 result, err := svc.UpdateWebACL(input) 1401 if err != nil { 1402 if aerr, ok := err.(awserr.Error); ok { 1403 switch aerr.Code() { 1404 case waf.ErrCodeStaleDataException: 1405 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 1406 case waf.ErrCodeInternalErrorException: 1407 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 1408 case waf.ErrCodeInvalidAccountException: 1409 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 1410 case waf.ErrCodeInvalidOperationException: 1411 fmt.Println(waf.ErrCodeInvalidOperationException, aerr.Error()) 1412 case waf.ErrCodeInvalidParameterException: 1413 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 1414 case waf.ErrCodeNonexistentContainerException: 1415 fmt.Println(waf.ErrCodeNonexistentContainerException, aerr.Error()) 1416 case waf.ErrCodeNonexistentItemException: 1417 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 1418 case waf.ErrCodeReferencedItemException: 1419 fmt.Println(waf.ErrCodeReferencedItemException, aerr.Error()) 1420 case waf.ErrCodeLimitsExceededException: 1421 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 1422 case waf.ErrCodeSubscriptionNotFoundException: 1423 fmt.Println(waf.ErrCodeSubscriptionNotFoundException, aerr.Error()) 1424 default: 1425 fmt.Println(aerr.Error()) 1426 } 1427 } else { 1428 // Print the error, cast err to awserr.Error to get the Code and 1429 // Message from an error. 1430 fmt.Println(err.Error()) 1431 } 1432 return 1433 } 1434 1435 fmt.Println(result) 1436 } 1437 1438 // To update an XSS match set 1439 // 1440 // The following example deletes an XssMatchTuple object (filters) in an XssMatchSet 1441 // with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5. 1442 func ExampleWAF_UpdateXssMatchSet_shared00() { 1443 svc := waf.New(session.New()) 1444 input := &waf.UpdateXssMatchSetInput{ 1445 ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"), 1446 Updates: []*waf.XssMatchSetUpdate{ 1447 { 1448 Action: aws.String("DELETE"), 1449 XssMatchTuple: &waf.XssMatchTuple{ 1450 FieldToMatch: &waf.FieldToMatch{ 1451 Type: aws.String("QUERY_STRING"), 1452 }, 1453 TextTransformation: aws.String("URL_DECODE"), 1454 }, 1455 }, 1456 }, 1457 XssMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"), 1458 } 1459 1460 result, err := svc.UpdateXssMatchSet(input) 1461 if err != nil { 1462 if aerr, ok := err.(awserr.Error); ok { 1463 switch aerr.Code() { 1464 case waf.ErrCodeInternalErrorException: 1465 fmt.Println(waf.ErrCodeInternalErrorException, aerr.Error()) 1466 case waf.ErrCodeInvalidAccountException: 1467 fmt.Println(waf.ErrCodeInvalidAccountException, aerr.Error()) 1468 case waf.ErrCodeInvalidOperationException: 1469 fmt.Println(waf.ErrCodeInvalidOperationException, aerr.Error()) 1470 case waf.ErrCodeInvalidParameterException: 1471 fmt.Println(waf.ErrCodeInvalidParameterException, aerr.Error()) 1472 case waf.ErrCodeNonexistentContainerException: 1473 fmt.Println(waf.ErrCodeNonexistentContainerException, aerr.Error()) 1474 case waf.ErrCodeNonexistentItemException: 1475 fmt.Println(waf.ErrCodeNonexistentItemException, aerr.Error()) 1476 case waf.ErrCodeStaleDataException: 1477 fmt.Println(waf.ErrCodeStaleDataException, aerr.Error()) 1478 case waf.ErrCodeLimitsExceededException: 1479 fmt.Println(waf.ErrCodeLimitsExceededException, aerr.Error()) 1480 default: 1481 fmt.Println(aerr.Error()) 1482 } 1483 } else { 1484 // Print the error, cast err to awserr.Error to get the Code and 1485 // Message from an error. 1486 fmt.Println(err.Error()) 1487 } 1488 return 1489 } 1490 1491 fmt.Println(result) 1492 }