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/smithy-go/middleware"
10	smithyhttp "github.com/aws/smithy-go/transport/http"
11)
12
13// Gets a list of all of the context keys referenced in the input policies. The
14// policies are supplied as a list of one or more strings. To get the context keys
15// from policies associated with an IAM user, group, or role, use
16// GetContextKeysForPrincipalPolicy. Context keys are variables maintained by AWS
17// and its services that provide details about the context of an API query request.
18// Context keys can be evaluated by testing against a value specified in an IAM
19// policy. Use GetContextKeysForCustomPolicy to understand what key names and
20// values you must supply when you call SimulateCustomPolicy. Note that all
21// parameters are shown in unencoded form here for clarity but must be URL encoded
22// to be included as a part of a real HTML request.
23func (c *Client) GetContextKeysForCustomPolicy(ctx context.Context, params *GetContextKeysForCustomPolicyInput, optFns ...func(*Options)) (*GetContextKeysForCustomPolicyOutput, error) {
24	if params == nil {
25		params = &GetContextKeysForCustomPolicyInput{}
26	}
27
28	result, metadata, err := c.invokeOperation(ctx, "GetContextKeysForCustomPolicy", params, optFns, addOperationGetContextKeysForCustomPolicyMiddlewares)
29	if err != nil {
30		return nil, err
31	}
32
33	out := result.(*GetContextKeysForCustomPolicyOutput)
34	out.ResultMetadata = metadata
35	return out, nil
36}
37
38type GetContextKeysForCustomPolicyInput struct {
39
40	// A list of policies for which you want the list of context keys referenced in
41	// those policies. Each document is specified as a string containing the complete,
42	// valid JSON text of an IAM policy. The regex pattern
43	// (http://wikipedia.org/wiki/regex) used to validate this parameter is a string of
44	// characters consisting of the following:
45	//
46	// * Any printable ASCII character ranging
47	// from the space character (\u0020) through the end of the ASCII character
48	// range
49	//
50	// * The printable characters in the Basic Latin and Latin-1 Supplement
51	// character set (through \u00FF)
52	//
53	// * The special characters tab (\u0009), line feed
54	// (\u000A), and carriage return (\u000D)
55	//
56	// This member is required.
57	PolicyInputList []string
58}
59
60// Contains the response to a successful GetContextKeysForPrincipalPolicy or
61// GetContextKeysForCustomPolicy request.
62type GetContextKeysForCustomPolicyOutput struct {
63
64	// The list of context keys that are referenced in the input policies.
65	ContextKeyNames []string
66
67	// Metadata pertaining to the operation's result.
68	ResultMetadata middleware.Metadata
69}
70
71func addOperationGetContextKeysForCustomPolicyMiddlewares(stack *middleware.Stack, options Options) (err error) {
72	err = stack.Serialize.Add(&awsAwsquery_serializeOpGetContextKeysForCustomPolicy{}, middleware.After)
73	if err != nil {
74		return err
75	}
76	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpGetContextKeysForCustomPolicy{}, middleware.After)
77	if err != nil {
78		return err
79	}
80	if err = addSetLoggerMiddleware(stack, options); err != nil {
81		return err
82	}
83	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
84		return err
85	}
86	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
87		return err
88	}
89	if err = addResolveEndpointMiddleware(stack, options); err != nil {
90		return err
91	}
92	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
93		return err
94	}
95	if err = addRetryMiddlewares(stack, options); err != nil {
96		return err
97	}
98	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
99		return err
100	}
101	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
102		return err
103	}
104	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
105		return err
106	}
107	if err = addClientUserAgent(stack); err != nil {
108		return err
109	}
110	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
111		return err
112	}
113	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
114		return err
115	}
116	if err = addOpGetContextKeysForCustomPolicyValidationMiddleware(stack); err != nil {
117		return err
118	}
119	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetContextKeysForCustomPolicy(options.Region), middleware.Before); err != nil {
120		return err
121	}
122	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
123		return err
124	}
125	if err = addResponseErrorMiddleware(stack); err != nil {
126		return err
127	}
128	if err = addRequestResponseLogging(stack, options); err != nil {
129		return err
130	}
131	return nil
132}
133
134func newServiceMetadataMiddleware_opGetContextKeysForCustomPolicy(region string) *awsmiddleware.RegisterServiceMetadata {
135	return &awsmiddleware.RegisterServiceMetadata{
136		Region:        region,
137		ServiceID:     ServiceID,
138		SigningName:   "iam",
139		OperationName: "GetContextKeysForCustomPolicy",
140	}
141}
142