api_op_CreateCertificate.go raw

   1  // Code generated by smithy-go-codegen DO NOT EDIT.
   2  
   3  package lightsail
   4  
   5  import (
   6  	"context"
   7  	"fmt"
   8  	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
   9  	"github.com/aws/aws-sdk-go-v2/service/lightsail/types"
  10  	"github.com/aws/smithy-go/middleware"
  11  	smithyhttp "github.com/aws/smithy-go/transport/http"
  12  )
  13  
  14  // Creates an SSL/TLS certificate for an Amazon Lightsail content delivery network
  15  // (CDN) distribution and a container service.
  16  //
  17  // After the certificate is valid, use the AttachCertificateToDistribution action
  18  // to use the certificate and its domains with your distribution. Or use the
  19  // UpdateContainerService action to use the certificate and its domains with your
  20  // container service.
  21  //
  22  // Only certificates created in the us-east-1 Amazon Web Services Region can be
  23  // attached to Lightsail distributions. Lightsail distributions are global
  24  // resources that can reference an origin in any Amazon Web Services Region, and
  25  // distribute its content globally. However, all distributions are located in the
  26  // us-east-1 Region.
  27  func (c *Client) CreateCertificate(ctx context.Context, params *CreateCertificateInput, optFns ...func(*Options)) (*CreateCertificateOutput, error) {
  28  	if params == nil {
  29  		params = &CreateCertificateInput{}
  30  	}
  31  
  32  	result, metadata, err := c.invokeOperation(ctx, "CreateCertificate", params, optFns, c.addOperationCreateCertificateMiddlewares)
  33  	if err != nil {
  34  		return nil, err
  35  	}
  36  
  37  	out := result.(*CreateCertificateOutput)
  38  	out.ResultMetadata = metadata
  39  	return out, nil
  40  }
  41  
  42  type CreateCertificateInput struct {
  43  
  44  	// The name for the certificate.
  45  	//
  46  	// This member is required.
  47  	CertificateName *string
  48  
  49  	// The domain name ( example.com ) for the certificate.
  50  	//
  51  	// This member is required.
  52  	DomainName *string
  53  
  54  	// An array of strings that specify the alternate domains ( example2.com ) and
  55  	// subdomains ( blog.example.com ) for the certificate.
  56  	//
  57  	// You can specify a maximum of nine alternate domains (in addition to the primary
  58  	// domain name).
  59  	//
  60  	// Wildcard domain entries ( *.example.com ) are not supported.
  61  	SubjectAlternativeNames []string
  62  
  63  	// The tag keys and optional values to add to the certificate during create.
  64  	//
  65  	// Use the TagResource action to tag a resource after it's created.
  66  	Tags []types.Tag
  67  
  68  	noSmithyDocumentSerde
  69  }
  70  
  71  type CreateCertificateOutput struct {
  72  
  73  	// An object that describes the certificate created.
  74  	Certificate *types.CertificateSummary
  75  
  76  	// An array of objects that describe the result of the action, such as the status
  77  	// of the request, the timestamp of the request, and the resources affected by the
  78  	// request.
  79  	Operations []types.Operation
  80  
  81  	// Metadata pertaining to the operation's result.
  82  	ResultMetadata middleware.Metadata
  83  
  84  	noSmithyDocumentSerde
  85  }
  86  
  87  func (c *Client) addOperationCreateCertificateMiddlewares(stack *middleware.Stack, options Options) (err error) {
  88  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  89  		return err
  90  	}
  91  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateCertificate{}, middleware.After)
  92  	if err != nil {
  93  		return err
  94  	}
  95  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateCertificate{}, middleware.After)
  96  	if err != nil {
  97  		return err
  98  	}
  99  	if err := addProtocolFinalizerMiddlewares(stack, options, "CreateCertificate"); err != nil {
 100  		return fmt.Errorf("add protocol finalizers: %v", err)
 101  	}
 102  
 103  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
 104  		return err
 105  	}
 106  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 107  		return err
 108  	}
 109  	if err = addClientRequestID(stack); err != nil {
 110  		return err
 111  	}
 112  	if err = addComputeContentLength(stack); err != nil {
 113  		return err
 114  	}
 115  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 116  		return err
 117  	}
 118  	if err = addComputePayloadSHA256(stack); err != nil {
 119  		return err
 120  	}
 121  	if err = addRetry(stack, options); err != nil {
 122  		return err
 123  	}
 124  	if err = addRawResponseToMetadata(stack); err != nil {
 125  		return err
 126  	}
 127  	if err = addRecordResponseTiming(stack); err != nil {
 128  		return err
 129  	}
 130  	if err = addSpanRetryLoop(stack, options); err != nil {
 131  		return err
 132  	}
 133  	if err = addClientUserAgent(stack, options); err != nil {
 134  		return err
 135  	}
 136  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 137  		return err
 138  	}
 139  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 140  		return err
 141  	}
 142  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 143  		return err
 144  	}
 145  	if err = addTimeOffsetBuild(stack, c); err != nil {
 146  		return err
 147  	}
 148  	if err = addUserAgentRetryMode(stack, options); err != nil {
 149  		return err
 150  	}
 151  	if err = addCredentialSource(stack, options); err != nil {
 152  		return err
 153  	}
 154  	if err = addOpCreateCertificateValidationMiddleware(stack); err != nil {
 155  		return err
 156  	}
 157  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateCertificate(options.Region), middleware.Before); err != nil {
 158  		return err
 159  	}
 160  	if err = addRecursionDetection(stack); 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  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 173  		return err
 174  	}
 175  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 176  		return err
 177  	}
 178  	if err = addInterceptAttempt(stack, options); err != nil {
 179  		return err
 180  	}
 181  	if err = addInterceptors(stack, options); err != nil {
 182  		return err
 183  	}
 184  	return nil
 185  }
 186  
 187  func newServiceMetadataMiddleware_opCreateCertificate(region string) *awsmiddleware.RegisterServiceMetadata {
 188  	return &awsmiddleware.RegisterServiceMetadata{
 189  		Region:        region,
 190  		ServiceID:     ServiceID,
 191  		OperationName: "CreateCertificate",
 192  	}
 193  }
 194