1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package emr
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/emr/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Maps a user or group to the Amazon EMR Studio specified by StudioId, and applies
15// a session policy to refine Studio permissions for that user or group. Use
16// CreateStudioSessionMapping to assign users to a Studio when you use Amazon Web
17// Services SSO authentication. For instructions on how to assign users to a Studio
18// when you use IAM authentication, see Assign a user or group to your EMR Studio
19// (https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-studio-manage-users.html#emr-studio-assign-users-groups).
20func (c *Client) CreateStudioSessionMapping(ctx context.Context, params *CreateStudioSessionMappingInput, optFns ...func(*Options)) (*CreateStudioSessionMappingOutput, error) {
21	if params == nil {
22		params = &CreateStudioSessionMappingInput{}
23	}
24
25	result, metadata, err := c.invokeOperation(ctx, "CreateStudioSessionMapping", params, optFns, c.addOperationCreateStudioSessionMappingMiddlewares)
26	if err != nil {
27		return nil, err
28	}
29
30	out := result.(*CreateStudioSessionMappingOutput)
31	out.ResultMetadata = metadata
32	return out, nil
33}
34
35type CreateStudioSessionMappingInput struct {
36
37	// Specifies whether the identity to map to the Amazon EMR Studio is a user or a
38	// group.
39	//
40	// This member is required.
41	IdentityType types.IdentityType
42
43	// The Amazon Resource Name (ARN) for the session policy that will be applied to
44	// the user or group. You should specify the ARN for the session policy that you
45	// want to apply, not the ARN of your user role. For more information, see Create
46	// an EMR Studio User Role with Session Policies
47	// (https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-studio-user-role.html).
48	//
49	// This member is required.
50	SessionPolicyArn *string
51
52	// The ID of the Amazon EMR Studio to which the user or group will be mapped.
53	//
54	// This member is required.
55	StudioId *string
56
57	// The globally unique identifier (GUID) of the user or group from the Amazon Web
58	// Services SSO Identity Store. For more information, see UserId
59	// (https://docs.aws.amazon.com/singlesignon/latest/IdentityStoreAPIReference/API_User.html#singlesignon-Type-User-UserId)
60	// and GroupId
61	// (https://docs.aws.amazon.com/singlesignon/latest/IdentityStoreAPIReference/API_Group.html#singlesignon-Type-Group-GroupId)
62	// in the Amazon Web Services SSO Identity Store API Reference. Either IdentityName
63	// or IdentityId must be specified, but not both.
64	IdentityId *string
65
66	// The name of the user or group. For more information, see UserName
67	// (https://docs.aws.amazon.com/singlesignon/latest/IdentityStoreAPIReference/API_User.html#singlesignon-Type-User-UserName)
68	// and DisplayName
69	// (https://docs.aws.amazon.com/singlesignon/latest/IdentityStoreAPIReference/API_Group.html#singlesignon-Type-Group-DisplayName)
70	// in the Amazon Web Services SSO Identity Store API Reference. Either IdentityName
71	// or IdentityId must be specified, but not both.
72	IdentityName *string
73
74	noSmithyDocumentSerde
75}
76
77type CreateStudioSessionMappingOutput struct {
78	// Metadata pertaining to the operation's result.
79	ResultMetadata middleware.Metadata
80
81	noSmithyDocumentSerde
82}
83
84func (c *Client) addOperationCreateStudioSessionMappingMiddlewares(stack *middleware.Stack, options Options) (err error) {
85	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateStudioSessionMapping{}, middleware.After)
86	if err != nil {
87		return err
88	}
89	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateStudioSessionMapping{}, middleware.After)
90	if err != nil {
91		return err
92	}
93	if err = addSetLoggerMiddleware(stack, options); err != nil {
94		return err
95	}
96	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
97		return err
98	}
99	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
100		return err
101	}
102	if err = addResolveEndpointMiddleware(stack, options); err != nil {
103		return err
104	}
105	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
106		return err
107	}
108	if err = addRetryMiddlewares(stack, options); err != nil {
109		return err
110	}
111	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
112		return err
113	}
114	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
115		return err
116	}
117	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
118		return err
119	}
120	if err = addClientUserAgent(stack); err != nil {
121		return err
122	}
123	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
124		return err
125	}
126	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
127		return err
128	}
129	if err = addOpCreateStudioSessionMappingValidationMiddleware(stack); err != nil {
130		return err
131	}
132	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateStudioSessionMapping(options.Region), middleware.Before); err != nil {
133		return err
134	}
135	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
136		return err
137	}
138	if err = addResponseErrorMiddleware(stack); err != nil {
139		return err
140	}
141	if err = addRequestResponseLogging(stack, options); err != nil {
142		return err
143	}
144	return nil
145}
146
147func newServiceMetadataMiddleware_opCreateStudioSessionMapping(region string) *awsmiddleware.RegisterServiceMetadata {
148	return &awsmiddleware.RegisterServiceMetadata{
149		Region:        region,
150		ServiceID:     ServiceID,
151		SigningName:   "elasticmapreduce",
152		OperationName: "CreateStudioSessionMapping",
153	}
154}
155