1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package workmail 4 5import ( 6 "context" 7 "fmt" 8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 9 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 10 "github.com/aws/aws-sdk-go-v2/service/workmail/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Lists the mailbox permissions associated with a user, group, or resource 16// mailbox. 17func (c *Client) ListMailboxPermissions(ctx context.Context, params *ListMailboxPermissionsInput, optFns ...func(*Options)) (*ListMailboxPermissionsOutput, error) { 18 if params == nil { 19 params = &ListMailboxPermissionsInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "ListMailboxPermissions", params, optFns, c.addOperationListMailboxPermissionsMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*ListMailboxPermissionsOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type ListMailboxPermissionsInput struct { 33 34 // The identifier of the user, group, or resource for which to list mailbox 35 // permissions. 36 // 37 // This member is required. 38 EntityId *string 39 40 // The identifier of the organization under which the user, group, or resource 41 // exists. 42 // 43 // This member is required. 44 OrganizationId *string 45 46 // The maximum number of results to return in a single call. 47 MaxResults *int32 48 49 // The token to use to retrieve the next page of results. The first call does not 50 // contain any tokens. 51 NextToken *string 52 53 noSmithyDocumentSerde 54} 55 56type ListMailboxPermissionsOutput struct { 57 58 // The token to use to retrieve the next page of results. The value is "null" when 59 // there are no more results to return. 60 NextToken *string 61 62 // One page of the user, group, or resource mailbox permissions. 63 Permissions []types.Permission 64 65 // Metadata pertaining to the operation's result. 66 ResultMetadata middleware.Metadata 67 68 noSmithyDocumentSerde 69} 70 71func (c *Client) addOperationListMailboxPermissionsMiddlewares(stack *middleware.Stack, options Options) (err error) { 72 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListMailboxPermissions{}, middleware.After) 73 if err != nil { 74 return err 75 } 76 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListMailboxPermissions{}, 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 = addOpListMailboxPermissionsValidationMiddleware(stack); err != nil { 117 return err 118 } 119 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListMailboxPermissions(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 134// ListMailboxPermissionsAPIClient is a client that implements the 135// ListMailboxPermissions operation. 136type ListMailboxPermissionsAPIClient interface { 137 ListMailboxPermissions(context.Context, *ListMailboxPermissionsInput, ...func(*Options)) (*ListMailboxPermissionsOutput, error) 138} 139 140var _ ListMailboxPermissionsAPIClient = (*Client)(nil) 141 142// ListMailboxPermissionsPaginatorOptions is the paginator options for 143// ListMailboxPermissions 144type ListMailboxPermissionsPaginatorOptions struct { 145 // The maximum number of results to return in a single call. 146 Limit int32 147 148 // Set to true if pagination should stop if the service returns a pagination token 149 // that matches the most recent token provided to the service. 150 StopOnDuplicateToken bool 151} 152 153// ListMailboxPermissionsPaginator is a paginator for ListMailboxPermissions 154type ListMailboxPermissionsPaginator struct { 155 options ListMailboxPermissionsPaginatorOptions 156 client ListMailboxPermissionsAPIClient 157 params *ListMailboxPermissionsInput 158 nextToken *string 159 firstPage bool 160} 161 162// NewListMailboxPermissionsPaginator returns a new ListMailboxPermissionsPaginator 163func NewListMailboxPermissionsPaginator(client ListMailboxPermissionsAPIClient, params *ListMailboxPermissionsInput, optFns ...func(*ListMailboxPermissionsPaginatorOptions)) *ListMailboxPermissionsPaginator { 164 if params == nil { 165 params = &ListMailboxPermissionsInput{} 166 } 167 168 options := ListMailboxPermissionsPaginatorOptions{} 169 if params.MaxResults != nil { 170 options.Limit = *params.MaxResults 171 } 172 173 for _, fn := range optFns { 174 fn(&options) 175 } 176 177 return &ListMailboxPermissionsPaginator{ 178 options: options, 179 client: client, 180 params: params, 181 firstPage: true, 182 } 183} 184 185// HasMorePages returns a boolean indicating whether more pages are available 186func (p *ListMailboxPermissionsPaginator) HasMorePages() bool { 187 return p.firstPage || p.nextToken != nil 188} 189 190// NextPage retrieves the next ListMailboxPermissions page. 191func (p *ListMailboxPermissionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListMailboxPermissionsOutput, error) { 192 if !p.HasMorePages() { 193 return nil, fmt.Errorf("no more pages available") 194 } 195 196 params := *p.params 197 params.NextToken = p.nextToken 198 199 var limit *int32 200 if p.options.Limit > 0 { 201 limit = &p.options.Limit 202 } 203 params.MaxResults = limit 204 205 result, err := p.client.ListMailboxPermissions(ctx, ¶ms, optFns...) 206 if err != nil { 207 return nil, err 208 } 209 p.firstPage = false 210 211 prevToken := p.nextToken 212 p.nextToken = result.NextToken 213 214 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 215 p.nextToken = nil 216 } 217 218 return result, nil 219} 220 221func newServiceMetadataMiddleware_opListMailboxPermissions(region string) *awsmiddleware.RegisterServiceMetadata { 222 return &awsmiddleware.RegisterServiceMetadata{ 223 Region: region, 224 ServiceID: ServiceID, 225 SigningName: "workmail", 226 OperationName: "ListMailboxPermissions", 227 } 228} 229