2017-05-11 14:39:54 +00:00
|
|
|
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
|
|
|
|
|
|
|
package wafregional_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-07-23 07:51:42 +00:00
|
|
|
"strings"
|
2017-05-11 14:39:54 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
2017-07-23 07:51:42 +00:00
|
|
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
2017-05-11 14:39:54 +00:00
|
|
|
"github.com/aws/aws-sdk-go/aws/session"
|
|
|
|
"github.com/aws/aws-sdk-go/service/waf"
|
|
|
|
"github.com/aws/aws-sdk-go/service/wafregional"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ time.Duration
|
2017-07-23 07:51:42 +00:00
|
|
|
var _ strings.Reader
|
|
|
|
var _ aws.Config
|
2017-05-11 14:39:54 +00:00
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
func parseTime(layout, value string) *time.Time {
|
|
|
|
t, err := time.Parse(layout, value)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
panic(err)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
2017-07-23 07:51:42 +00:00
|
|
|
return &t
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To create an IP set
|
|
|
|
//
|
|
|
|
// The following example creates an IP match set named MyIPSetFriendlyName.
|
|
|
|
func ExampleWAFRegional_CreateIPSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.CreateIPSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
Name: aws.String("MyIPSetFriendlyName"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.CreateIPSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFDisallowedNameException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFDisallowedNameException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To create a rule
|
|
|
|
//
|
|
|
|
// The following example creates a rule named WAFByteHeaderRule.
|
|
|
|
func ExampleWAFRegional_CreateRule_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.CreateRuleInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
MetricName: aws.String("WAFByteHeaderRule"),
|
|
|
|
Name: aws.String("WAFByteHeaderRule"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.CreateRule(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFDisallowedNameException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFDisallowedNameException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To create a size constraint
|
|
|
|
//
|
|
|
|
// The following example creates size constraint set named MySampleSizeConstraintSet.
|
|
|
|
func ExampleWAFRegional_CreateSizeConstraintSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.CreateSizeConstraintSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
Name: aws.String("MySampleSizeConstraintSet"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.CreateSizeConstraintSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFDisallowedNameException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFDisallowedNameException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To create a SQL injection match set
|
|
|
|
//
|
|
|
|
// The following example creates a SQL injection match set named MySQLInjectionMatchSet.
|
|
|
|
func ExampleWAFRegional_CreateSqlInjectionMatchSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.CreateSqlInjectionMatchSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
Name: aws.String("MySQLInjectionMatchSet"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.CreateSqlInjectionMatchSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFDisallowedNameException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFDisallowedNameException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To create a web ACL
|
|
|
|
//
|
|
|
|
// The following example creates a web ACL named CreateExample.
|
|
|
|
func ExampleWAFRegional_CreateWebACL_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.CreateWebACLInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
DefaultAction: &waf.WafAction{
|
|
|
|
Type: aws.String("ALLOW"),
|
2017-05-11 14:39:54 +00:00
|
|
|
},
|
2017-07-23 07:51:42 +00:00
|
|
|
MetricName: aws.String("CreateExample"),
|
|
|
|
Name: aws.String("CreateExample"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.CreateWebACL(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFDisallowedNameException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFDisallowedNameException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To create an XSS match set
|
|
|
|
//
|
|
|
|
// The following example creates an XSS match set named MySampleXssMatchSet.
|
|
|
|
func ExampleWAFRegional_CreateXssMatchSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.CreateXssMatchSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
Name: aws.String("MySampleXssMatchSet"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.CreateXssMatchSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFDisallowedNameException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFDisallowedNameException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To delete a byte match set
|
|
|
|
//
|
|
|
|
// The following example deletes a byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_DeleteByteMatchSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.DeleteByteMatchSetInput{
|
|
|
|
ByteMatchSetId: aws.String("exampleIDs3t-46da-4fdb-b8d5-abc321j569j5"),
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.DeleteByteMatchSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFReferencedItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFReferencedItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonEmptyEntityException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonEmptyEntityException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To delete an IP set
|
|
|
|
//
|
|
|
|
// The following example deletes an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_DeleteIPSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.DeleteIPSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
IPSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.DeleteIPSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFReferencedItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFReferencedItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonEmptyEntityException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonEmptyEntityException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To delete a rule
|
|
|
|
//
|
|
|
|
// The following example deletes a rule with the ID WAFRule-1-Example.
|
|
|
|
func ExampleWAFRegional_DeleteRule_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.DeleteRuleInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
RuleId: aws.String("WAFRule-1-Example"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.DeleteRule(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFReferencedItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFReferencedItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonEmptyEntityException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonEmptyEntityException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To delete a size constraint set
|
|
|
|
//
|
|
|
|
// The following example deletes a size constraint set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_DeleteSizeConstraintSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.DeleteSizeConstraintSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
SizeConstraintSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.DeleteSizeConstraintSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFReferencedItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFReferencedItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonEmptyEntityException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonEmptyEntityException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To delete a SQL injection match set
|
|
|
|
//
|
|
|
|
// The following example deletes a SQL injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_DeleteSqlInjectionMatchSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.DeleteSqlInjectionMatchSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
SqlInjectionMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.DeleteSqlInjectionMatchSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFReferencedItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFReferencedItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonEmptyEntityException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonEmptyEntityException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To delete a web ACL
|
|
|
|
//
|
|
|
|
// The following example deletes a web ACL with the ID example-46da-4444-5555-example.
|
|
|
|
func ExampleWAFRegional_DeleteWebACL_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.DeleteWebACLInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
WebACLId: aws.String("example-46da-4444-5555-example"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.DeleteWebACL(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFReferencedItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFReferencedItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonEmptyEntityException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonEmptyEntityException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To delete an XSS match set
|
|
|
|
//
|
|
|
|
// The following example deletes an XSS match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_DeleteXssMatchSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.DeleteXssMatchSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
XssMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.DeleteXssMatchSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFReferencedItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFReferencedItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonEmptyEntityException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonEmptyEntityException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To get a byte match set
|
|
|
|
//
|
|
|
|
// The following example returns the details of a byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_GetByteMatchSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.GetByteMatchSetInput{
|
|
|
|
ByteMatchSetId: aws.String("exampleIDs3t-46da-4fdb-b8d5-abc321j569j5"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.GetByteMatchSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To get a change token
|
|
|
|
//
|
|
|
|
// The following example returns a change token to use for a create, update or delete
|
|
|
|
// operation.
|
|
|
|
func ExampleWAFRegional_GetChangeToken_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.GetChangeTokenInput{}
|
2017-05-11 14:39:54 +00:00
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.GetChangeToken(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To get the change token status
|
|
|
|
//
|
|
|
|
// The following example returns the status of a change token with the ID abcd12f2-46da-4fdb-b8d5-fbd4c466928f.
|
|
|
|
func ExampleWAFRegional_GetChangeTokenStatus_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.GetChangeTokenStatusInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.GetChangeTokenStatus(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To get an IP set
|
|
|
|
//
|
|
|
|
// The following example returns the details of an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_GetIPSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.GetIPSetInput{
|
|
|
|
IPSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.GetIPSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To get a rule
|
|
|
|
//
|
|
|
|
// The following example returns the details of a rule with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_GetRule_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.GetRuleInput{
|
|
|
|
RuleId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.GetRule(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To get a sampled requests
|
|
|
|
//
|
|
|
|
// The following example returns detailed information about 100 requests --a sample--
|
|
|
|
// that AWS WAF randomly selects from among the first 5,000 requests that your AWS resource
|
|
|
|
// received between the time period 2016-09-27T15:50Z to 2016-09-27T15:50Z.
|
|
|
|
func ExampleWAFRegional_GetSampledRequests_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.GetSampledRequestsInput{
|
|
|
|
MaxItems: aws.Int64(100),
|
|
|
|
RuleId: aws.String("WAFRule-1-Example"),
|
|
|
|
TimeWindow: &waf.TimeWindow{
|
|
|
|
EndTime: parseTime("2006-01-02T15:04:05Z", "2016-09-27T15:50Z"),
|
|
|
|
StartTime: parseTime("2006-01-02T15:04:05Z", "2016-09-27T15:50Z"),
|
2017-05-11 14:39:54 +00:00
|
|
|
},
|
2017-07-23 07:51:42 +00:00
|
|
|
WebAclId: aws.String("createwebacl-1472061481310"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.GetSampledRequests(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To get a size constraint set
|
|
|
|
//
|
|
|
|
// The following example returns the details of a size constraint match set with the
|
|
|
|
// ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_GetSizeConstraintSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.GetSizeConstraintSetInput{
|
|
|
|
SizeConstraintSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.GetSizeConstraintSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To get a SQL injection match set
|
|
|
|
//
|
|
|
|
// The following example returns the details of a SQL injection match set with the ID
|
|
|
|
// example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_GetSqlInjectionMatchSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.GetSqlInjectionMatchSetInput{
|
|
|
|
SqlInjectionMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.GetSqlInjectionMatchSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To get a web ACL
|
|
|
|
//
|
|
|
|
// The following example returns the details of a web ACL with the ID createwebacl-1472061481310.
|
|
|
|
func ExampleWAFRegional_GetWebACL_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.GetWebACLInput{
|
|
|
|
WebACLId: aws.String("createwebacl-1472061481310"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.GetWebACL(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To get an XSS match set
|
|
|
|
//
|
|
|
|
// The following example returns the details of an XSS match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_GetXssMatchSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.GetXssMatchSetInput{
|
|
|
|
XssMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.GetXssMatchSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To list IP sets
|
|
|
|
//
|
|
|
|
// The following example returns an array of up to 100 IP match sets.
|
|
|
|
func ExampleWAFRegional_ListIPSets_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.ListIPSetsInput{
|
|
|
|
Limit: aws.Int64(100),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.ListIPSets(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To list rules
|
|
|
|
//
|
|
|
|
// The following example returns an array of up to 100 rules.
|
|
|
|
func ExampleWAFRegional_ListRules_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.ListRulesInput{
|
|
|
|
Limit: aws.Int64(100),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.ListRules(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To list a size constraint sets
|
|
|
|
//
|
|
|
|
// The following example returns an array of up to 100 size contraint match sets.
|
|
|
|
func ExampleWAFRegional_ListSizeConstraintSets_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.ListSizeConstraintSetsInput{
|
|
|
|
Limit: aws.Int64(100),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.ListSizeConstraintSets(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To list SQL injection match sets
|
|
|
|
//
|
|
|
|
// The following example returns an array of up to 100 SQL injection match sets.
|
|
|
|
func ExampleWAFRegional_ListSqlInjectionMatchSets_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.ListSqlInjectionMatchSetsInput{
|
|
|
|
Limit: aws.Int64(100),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.ListSqlInjectionMatchSets(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To list Web ACLs
|
|
|
|
//
|
|
|
|
// The following example returns an array of up to 100 web ACLs.
|
|
|
|
func ExampleWAFRegional_ListWebACLs_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.ListWebACLsInput{
|
|
|
|
Limit: aws.Int64(100),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.ListWebACLs(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To list XSS match sets
|
|
|
|
//
|
|
|
|
// The following example returns an array of up to 100 XSS match sets.
|
|
|
|
func ExampleWAFRegional_ListXssMatchSets_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.ListXssMatchSetsInput{
|
|
|
|
Limit: aws.Int64(100),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.ListXssMatchSets(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To update a byte match set
|
|
|
|
//
|
|
|
|
// The following example deletes a ByteMatchTuple object (filters) in an byte match
|
|
|
|
// set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_UpdateByteMatchSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.UpdateByteMatchSetInput{
|
|
|
|
ByteMatchSetId: aws.String("exampleIDs3t-46da-4fdb-b8d5-abc321j569j5"),
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
Updates: []*waf.ByteMatchSetUpdate{
|
|
|
|
{
|
|
|
|
Action: aws.String("DELETE"),
|
2017-05-11 14:39:54 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.UpdateByteMatchSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidOperationException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidOperationException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentContainerException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentContainerException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To update an IP set
|
|
|
|
//
|
|
|
|
// The following example deletes an IPSetDescriptor object in an IP match set with the
|
|
|
|
// ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_UpdateIPSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.UpdateIPSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
IPSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
|
|
|
Updates: []*waf.IPSetUpdate{
|
|
|
|
{
|
|
|
|
Action: aws.String("DELETE"),
|
2017-05-11 14:39:54 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.UpdateIPSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidOperationException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidOperationException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentContainerException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentContainerException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFReferencedItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFReferencedItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To update a rule
|
|
|
|
//
|
|
|
|
// The following example deletes a Predicate object in a rule with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_UpdateRule_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.UpdateRuleInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
RuleId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
|
|
|
Updates: []*waf.RuleUpdate{
|
|
|
|
{
|
|
|
|
Action: aws.String("DELETE"),
|
2017-05-11 14:39:54 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.UpdateRule(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidOperationException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidOperationException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentContainerException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentContainerException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFReferencedItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFReferencedItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To update a size constraint set
|
|
|
|
//
|
|
|
|
// The following example deletes a SizeConstraint object (filters) in a size constraint
|
|
|
|
// set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_UpdateSizeConstraintSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.UpdateSizeConstraintSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
SizeConstraintSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
|
|
|
Updates: []*waf.SizeConstraintSetUpdate{
|
|
|
|
{
|
|
|
|
Action: aws.String("DELETE"),
|
2017-05-11 14:39:54 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.UpdateSizeConstraintSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidOperationException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidOperationException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentContainerException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentContainerException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFReferencedItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFReferencedItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To update a SQL injection match set
|
|
|
|
//
|
|
|
|
// The following example deletes a SqlInjectionMatchTuple object (filters) in a SQL
|
|
|
|
// injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_UpdateSqlInjectionMatchSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.UpdateSqlInjectionMatchSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
SqlInjectionMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
|
|
|
Updates: []*waf.SqlInjectionMatchSetUpdate{
|
|
|
|
{
|
|
|
|
Action: aws.String("DELETE"),
|
2017-05-11 14:39:54 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.UpdateSqlInjectionMatchSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidOperationException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidOperationException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentContainerException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentContainerException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To update a Web ACL
|
|
|
|
//
|
|
|
|
// The following example deletes an ActivatedRule object in a WebACL with the ID webacl-1472061481310.
|
|
|
|
func ExampleWAFRegional_UpdateWebACL_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.UpdateWebACLInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
2017-05-11 14:39:54 +00:00
|
|
|
DefaultAction: &waf.WafAction{
|
2017-07-23 07:51:42 +00:00
|
|
|
Type: aws.String("ALLOW"),
|
2017-05-11 14:39:54 +00:00
|
|
|
},
|
|
|
|
Updates: []*waf.WebACLUpdate{
|
2017-07-23 07:51:42 +00:00
|
|
|
{
|
|
|
|
Action: aws.String("DELETE"),
|
2017-05-11 14:39:54 +00:00
|
|
|
},
|
|
|
|
},
|
2017-07-23 07:51:42 +00:00
|
|
|
WebACLId: aws.String("webacl-1472061481310"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.UpdateWebACL(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidOperationException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidOperationException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentContainerException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentContainerException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFReferencedItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFReferencedItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
2018-01-16 13:20:59 +00:00
|
|
|
case wafregional.ErrCodeWAFSubscriptionNotFoundException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFSubscriptionNotFoundException, aerr.Error())
|
2017-07-23 07:51:42 +00:00
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
// To update an XSS match set
|
|
|
|
//
|
|
|
|
// The following example deletes an XssMatchTuple object (filters) in an XssMatchSet
|
|
|
|
// with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
|
|
|
|
func ExampleWAFRegional_UpdateXssMatchSet_shared00() {
|
|
|
|
svc := wafregional.New(session.New())
|
|
|
|
input := &waf.UpdateXssMatchSetInput{
|
|
|
|
ChangeToken: aws.String("abcd12f2-46da-4fdb-b8d5-fbd4c466928f"),
|
|
|
|
Updates: []*waf.XssMatchSetUpdate{
|
|
|
|
{
|
|
|
|
Action: aws.String("DELETE"),
|
2017-05-11 14:39:54 +00:00
|
|
|
},
|
|
|
|
},
|
2017-07-23 07:51:42 +00:00
|
|
|
XssMatchSetId: aws.String("example1ds3t-46da-4fdb-b8d5-abc321j569j5"),
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
result, err := svc.UpdateXssMatchSet(input)
|
2017-05-11 14:39:54 +00:00
|
|
|
if err != nil {
|
2017-07-23 07:51:42 +00:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case wafregional.ErrCodeWAFInternalErrorException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInternalErrorException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidAccountException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidAccountException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidOperationException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidOperationException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFInvalidParameterException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFInvalidParameterException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentContainerException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentContainerException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFNonexistentItemException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFNonexistentItemException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFStaleDataException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFStaleDataException, aerr.Error())
|
|
|
|
case wafregional.ErrCodeWAFLimitsExceededException:
|
|
|
|
fmt.Println(wafregional.ErrCodeWAFLimitsExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 14:39:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 07:51:42 +00:00
|
|
|
fmt.Println(result)
|
2017-05-11 14:39:54 +00:00
|
|
|
}
|