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