1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package apigateway 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/apigateway/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12 "time" 13) 14 15// Create an ApiKey resource. AWS CLI 16// (https://docs.aws.amazon.com/cli/latest/reference/apigateway/create-api-key.html) 17func (c *Client) CreateApiKey(ctx context.Context, params *CreateApiKeyInput, optFns ...func(*Options)) (*CreateApiKeyOutput, error) { 18 if params == nil { 19 params = &CreateApiKeyInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "CreateApiKey", params, optFns, addOperationCreateApiKeyMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*CreateApiKeyOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32// Request to create an ApiKey resource. 33type CreateApiKeyInput struct { 34 35 // An AWS Marketplace customer identifier , when integrating with the AWS SaaS 36 // Marketplace. 37 CustomerId *string 38 39 // The description of the ApiKey. 40 Description *string 41 42 // Specifies whether the ApiKey can be used by callers. 43 Enabled bool 44 45 // Specifies whether (true) or not (false) the key identifier is distinct from the 46 // created API key value. This parameter is deprecated and should not be used. 47 GenerateDistinctId bool 48 49 // The name of the ApiKey. 50 Name *string 51 52 // DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key. 53 StageKeys []types.StageKey 54 55 // The key-value map of strings. The valid character set is [a-zA-Z+-=._:/]. The 56 // tag key can be up to 128 characters and must not start with aws:. The tag value 57 // can be up to 256 characters. 58 Tags map[string]string 59 60 // Specifies a value of the API key. 61 Value *string 62} 63 64// A resource that can be distributed to callers for executing Method resources 65// that require an API key. API keys can be mapped to any Stage on any RestApi, 66// which indicates that the callers with the API key can make requests to that 67// stage. Use API Keys 68// (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-api-keys.html) 69type CreateApiKeyOutput struct { 70 71 // The timestamp when the API Key was created. 72 CreatedDate *time.Time 73 74 // An AWS Marketplace customer identifier , when integrating with the AWS SaaS 75 // Marketplace. 76 CustomerId *string 77 78 // The description of the API Key. 79 Description *string 80 81 // Specifies whether the API Key can be used by callers. 82 Enabled bool 83 84 // The identifier of the API Key. 85 Id *string 86 87 // The timestamp when the API Key was last updated. 88 LastUpdatedDate *time.Time 89 90 // The name of the API Key. 91 Name *string 92 93 // A list of Stage resources that are associated with the ApiKey resource. 94 StageKeys []string 95 96 // The collection of tags. Each tag element is associated with a given resource. 97 Tags map[string]string 98 99 // The value of the API Key. 100 Value *string 101 102 // Metadata pertaining to the operation's result. 103 ResultMetadata middleware.Metadata 104} 105 106func addOperationCreateApiKeyMiddlewares(stack *middleware.Stack, options Options) (err error) { 107 err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateApiKey{}, middleware.After) 108 if err != nil { 109 return err 110 } 111 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateApiKey{}, middleware.After) 112 if err != nil { 113 return err 114 } 115 if err = addSetLoggerMiddleware(stack, options); err != nil { 116 return err 117 } 118 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 119 return err 120 } 121 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 122 return err 123 } 124 if err = addResolveEndpointMiddleware(stack, options); err != nil { 125 return err 126 } 127 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 128 return err 129 } 130 if err = addRetryMiddlewares(stack, options); err != nil { 131 return err 132 } 133 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 134 return err 135 } 136 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 137 return err 138 } 139 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 140 return err 141 } 142 if err = addClientUserAgent(stack); err != nil { 143 return err 144 } 145 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 146 return err 147 } 148 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 149 return err 150 } 151 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateApiKey(options.Region), middleware.Before); err != nil { 152 return err 153 } 154 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 155 return err 156 } 157 if err = addResponseErrorMiddleware(stack); err != nil { 158 return err 159 } 160 if err = addAcceptHeader(stack); err != nil { 161 return err 162 } 163 if err = addRequestResponseLogging(stack, options); err != nil { 164 return err 165 } 166 return nil 167} 168 169func newServiceMetadataMiddleware_opCreateApiKey(region string) *awsmiddleware.RegisterServiceMetadata { 170 return &awsmiddleware.RegisterServiceMetadata{ 171 Region: region, 172 ServiceID: ServiceID, 173 SigningName: "apigateway", 174 OperationName: "CreateApiKey", 175 } 176} 177