1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package sns 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/sns/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Creates a topic to which notifications can be published. Users can create at 15// most 100,000 standard topics (at most 1,000 FIFO topics). For more information, 16// see https://aws.amazon.com/sns (http://aws.amazon.com/sns/). This action is 17// idempotent, so if the requester already owns a topic with the specified name, 18// that topic's ARN is returned without creating a new topic. 19func (c *Client) CreateTopic(ctx context.Context, params *CreateTopicInput, optFns ...func(*Options)) (*CreateTopicOutput, error) { 20 if params == nil { 21 params = &CreateTopicInput{} 22 } 23 24 result, metadata, err := c.invokeOperation(ctx, "CreateTopic", params, optFns, addOperationCreateTopicMiddlewares) 25 if err != nil { 26 return nil, err 27 } 28 29 out := result.(*CreateTopicOutput) 30 out.ResultMetadata = metadata 31 return out, nil 32} 33 34// Input for CreateTopic action. 35type CreateTopicInput struct { 36 37 // The name of the topic you want to create. Constraints: Topic names must be made 38 // up of only uppercase and lowercase ASCII letters, numbers, underscores, and 39 // hyphens, and must be between 1 and 256 characters long. For a FIFO 40 // (first-in-first-out) topic, the name must end with the .fifo suffix. 41 // 42 // This member is required. 43 Name *string 44 45 // A map of attributes with their corresponding values. The following lists the 46 // names, descriptions, and values of the special request parameters that the 47 // CreateTopic action uses: 48 // 49 // * DeliveryPolicy – The policy that defines how Amazon 50 // SNS retries failed deliveries to HTTP/S endpoints. 51 // 52 // * DisplayName – The display 53 // name to use for a topic with SMS subscriptions. 54 // 55 // * FifoTopic – Set to true to 56 // create a FIFO topic. 57 // 58 // * Policy – The policy that defines who can access your 59 // topic. By default, only the topic owner can publish or subscribe to the 60 // topic. 61 // 62 // The following attribute applies only to server-side-encryption 63 // (https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html): 64 // 65 // * 66 // KmsMasterKeyId – The ID of an AWS-managed customer master key (CMK) for Amazon 67 // SNS or a custom CMK. For more information, see Key Terms 68 // (https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html#sse-key-terms). 69 // For more examples, see KeyId 70 // (https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters) 71 // in the AWS Key Management Service API Reference. 72 // 73 // The following attributes apply 74 // only to FIFO topics 75 // (https://docs.aws.amazon.com/sns/latest/dg/sns-fifo-topics.html): 76 // 77 // * FifoTopic – 78 // When this is set to true, a FIFO topic is created. 79 // 80 // * ContentBasedDeduplication 81 // – Enables content-based deduplication for FIFO topics. 82 // 83 // * By default, 84 // ContentBasedDeduplication is set to false. If you create a FIFO topic and this 85 // attribute is false, you must specify a value for the MessageDeduplicationId 86 // parameter for the Publish 87 // (https://docs.aws.amazon.com/sns/latest/api/API_Publish.html) action. 88 // 89 // * When 90 // you set ContentBasedDeduplication to true, Amazon SNS uses a SHA-256 hash to 91 // generate the MessageDeduplicationId using the body of the message (but not the 92 // attributes of the message). (Optional) To override the generated value, you can 93 // specify a value for the the MessageDeduplicationId parameter for the Publish 94 // action. 95 Attributes map[string]string 96 97 // The list of tags to add to a new topic. To be able to tag a topic on creation, 98 // you must have the sns:CreateTopic and sns:TagResource permissions. 99 Tags []types.Tag 100} 101 102// Response from CreateTopic action. 103type CreateTopicOutput struct { 104 105 // The Amazon Resource Name (ARN) assigned to the created topic. 106 TopicArn *string 107 108 // Metadata pertaining to the operation's result. 109 ResultMetadata middleware.Metadata 110} 111 112func addOperationCreateTopicMiddlewares(stack *middleware.Stack, options Options) (err error) { 113 err = stack.Serialize.Add(&awsAwsquery_serializeOpCreateTopic{}, middleware.After) 114 if err != nil { 115 return err 116 } 117 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpCreateTopic{}, middleware.After) 118 if err != nil { 119 return err 120 } 121 if err = addSetLoggerMiddleware(stack, options); err != nil { 122 return err 123 } 124 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 125 return err 126 } 127 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 128 return err 129 } 130 if err = addResolveEndpointMiddleware(stack, options); err != nil { 131 return err 132 } 133 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 134 return err 135 } 136 if err = addRetryMiddlewares(stack, options); err != nil { 137 return err 138 } 139 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 140 return err 141 } 142 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 143 return err 144 } 145 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 146 return err 147 } 148 if err = addClientUserAgent(stack); err != nil { 149 return err 150 } 151 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 152 return err 153 } 154 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 155 return err 156 } 157 if err = addOpCreateTopicValidationMiddleware(stack); err != nil { 158 return err 159 } 160 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateTopic(options.Region), middleware.Before); err != nil { 161 return err 162 } 163 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 164 return err 165 } 166 if err = addResponseErrorMiddleware(stack); err != nil { 167 return err 168 } 169 if err = addRequestResponseLogging(stack, options); err != nil { 170 return err 171 } 172 return nil 173} 174 175func newServiceMetadataMiddleware_opCreateTopic(region string) *awsmiddleware.RegisterServiceMetadata { 176 return &awsmiddleware.RegisterServiceMetadata{ 177 Region: region, 178 ServiceID: ServiceID, 179 SigningName: "sns", 180 OperationName: "CreateTopic", 181 } 182} 183