1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package iam
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/iam/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Uploads an X.509 signing certificate and associates it with the specified IAM
15// user. Some AWS services require you to use certificates to validate requests
16// that are signed with a corresponding private key. When you upload the
17// certificate, its default status is Active. For information about when you would
18// use an X.509 signing certificate, see Managing server certificates in IAM
19// (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_server-certs.html)
20// in the IAM User Guide. If the UserName is not specified, the IAM user name is
21// determined implicitly based on the AWS access key ID used to sign the request.
22// This operation works for access keys under the AWS account. Consequently, you
23// can use this operation to manage AWS account root user credentials even if the
24// AWS account has no associated users. Because the body of an X.509 certificate
25// can be large, you should use POST rather than GET when calling
26// UploadSigningCertificate. For information about setting up signatures and
27// authorization through the API, see Signing AWS API requests
28// (https://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html) in
29// the AWS General Reference. For general information about using the Query API
30// with IAM, see Making query requests
31// (https://docs.aws.amazon.com/IAM/latest/UserGuide/IAM_UsingQueryAPI.html) in the
32// IAM User Guide.
33func (c *Client) UploadSigningCertificate(ctx context.Context, params *UploadSigningCertificateInput, optFns ...func(*Options)) (*UploadSigningCertificateOutput, error) {
34	if params == nil {
35		params = &UploadSigningCertificateInput{}
36	}
37
38	result, metadata, err := c.invokeOperation(ctx, "UploadSigningCertificate", params, optFns, addOperationUploadSigningCertificateMiddlewares)
39	if err != nil {
40		return nil, err
41	}
42
43	out := result.(*UploadSigningCertificateOutput)
44	out.ResultMetadata = metadata
45	return out, nil
46}
47
48type UploadSigningCertificateInput struct {
49
50	// The contents of the signing certificate. The regex pattern
51	// (http://wikipedia.org/wiki/regex) used to validate this parameter is a string of
52	// characters consisting of the following:
53	//
54	// * Any printable ASCII character ranging
55	// from the space character (\u0020) through the end of the ASCII character
56	// range
57	//
58	// * The printable characters in the Basic Latin and Latin-1 Supplement
59	// character set (through \u00FF)
60	//
61	// * The special characters tab (\u0009), line feed
62	// (\u000A), and carriage return (\u000D)
63	//
64	// This member is required.
65	CertificateBody *string
66
67	// The name of the user the signing certificate is for. This parameter allows
68	// (through its regex pattern (http://wikipedia.org/wiki/regex)) a string of
69	// characters consisting of upper and lowercase alphanumeric characters with no
70	// spaces. You can also include any of the following characters: _+=,.@-
71	UserName *string
72}
73
74// Contains the response to a successful UploadSigningCertificate request.
75type UploadSigningCertificateOutput struct {
76
77	// Information about the certificate.
78	//
79	// This member is required.
80	Certificate *types.SigningCertificate
81
82	// Metadata pertaining to the operation's result.
83	ResultMetadata middleware.Metadata
84}
85
86func addOperationUploadSigningCertificateMiddlewares(stack *middleware.Stack, options Options) (err error) {
87	err = stack.Serialize.Add(&awsAwsquery_serializeOpUploadSigningCertificate{}, middleware.After)
88	if err != nil {
89		return err
90	}
91	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpUploadSigningCertificate{}, middleware.After)
92	if err != nil {
93		return err
94	}
95	if err = addSetLoggerMiddleware(stack, options); err != nil {
96		return err
97	}
98	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
99		return err
100	}
101	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
102		return err
103	}
104	if err = addResolveEndpointMiddleware(stack, options); err != nil {
105		return err
106	}
107	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
108		return err
109	}
110	if err = addRetryMiddlewares(stack, options); err != nil {
111		return err
112	}
113	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
114		return err
115	}
116	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
117		return err
118	}
119	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
120		return err
121	}
122	if err = addClientUserAgent(stack); err != nil {
123		return err
124	}
125	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
126		return err
127	}
128	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
129		return err
130	}
131	if err = addOpUploadSigningCertificateValidationMiddleware(stack); err != nil {
132		return err
133	}
134	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUploadSigningCertificate(options.Region), middleware.Before); err != nil {
135		return err
136	}
137	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
138		return err
139	}
140	if err = addResponseErrorMiddleware(stack); err != nil {
141		return err
142	}
143	if err = addRequestResponseLogging(stack, options); err != nil {
144		return err
145	}
146	return nil
147}
148
149func newServiceMetadataMiddleware_opUploadSigningCertificate(region string) *awsmiddleware.RegisterServiceMetadata {
150	return &awsmiddleware.RegisterServiceMetadata{
151		Region:        region,
152		ServiceID:     ServiceID,
153		SigningName:   "iam",
154		OperationName: "UploadSigningCertificate",
155	}
156}
157