1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package clouddirectory 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/clouddirectory/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Returns a paginated list of child objects that are associated with a given 16// object. 17func (c *Client) ListObjectChildren(ctx context.Context, params *ListObjectChildrenInput, optFns ...func(*Options)) (*ListObjectChildrenOutput, error) { 18 if params == nil { 19 params = &ListObjectChildrenInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "ListObjectChildren", params, optFns, addOperationListObjectChildrenMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*ListObjectChildrenOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type ListObjectChildrenInput struct { 33 34 // The Amazon Resource Name (ARN) that is associated with the Directory where the 35 // object resides. For more information, see arns. 36 // 37 // This member is required. 38 DirectoryArn *string 39 40 // The reference that identifies the object for which child objects are being 41 // listed. 42 // 43 // This member is required. 44 ObjectReference *types.ObjectReference 45 46 // Represents the manner and timing in which the successful write or update of an 47 // object is reflected in a subsequent read operation of that same object. 48 ConsistencyLevel types.ConsistencyLevel 49 50 // The maximum number of items to be retrieved in a single call. This is an 51 // approximate number. 52 MaxResults *int32 53 54 // The pagination token. 55 NextToken *string 56} 57 58type ListObjectChildrenOutput struct { 59 60 // Children structure, which is a map with key as the LinkName and ObjectIdentifier 61 // as the value. 62 Children map[string]string 63 64 // The pagination token. 65 NextToken *string 66 67 // Metadata pertaining to the operation's result. 68 ResultMetadata middleware.Metadata 69} 70 71func addOperationListObjectChildrenMiddlewares(stack *middleware.Stack, options Options) (err error) { 72 err = stack.Serialize.Add(&awsRestjson1_serializeOpListObjectChildren{}, middleware.After) 73 if err != nil { 74 return err 75 } 76 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListObjectChildren{}, 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 = addOpListObjectChildrenValidationMiddleware(stack); err != nil { 117 return err 118 } 119 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListObjectChildren(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// ListObjectChildrenAPIClient is a client that implements the ListObjectChildren 135// operation. 136type ListObjectChildrenAPIClient interface { 137 ListObjectChildren(context.Context, *ListObjectChildrenInput, ...func(*Options)) (*ListObjectChildrenOutput, error) 138} 139 140var _ ListObjectChildrenAPIClient = (*Client)(nil) 141 142// ListObjectChildrenPaginatorOptions is the paginator options for 143// ListObjectChildren 144type ListObjectChildrenPaginatorOptions struct { 145 // The maximum number of items to be retrieved in a single call. This is an 146 // approximate number. 147 Limit int32 148 149 // Set to true if pagination should stop if the service returns a pagination token 150 // that matches the most recent token provided to the service. 151 StopOnDuplicateToken bool 152} 153 154// ListObjectChildrenPaginator is a paginator for ListObjectChildren 155type ListObjectChildrenPaginator struct { 156 options ListObjectChildrenPaginatorOptions 157 client ListObjectChildrenAPIClient 158 params *ListObjectChildrenInput 159 nextToken *string 160 firstPage bool 161} 162 163// NewListObjectChildrenPaginator returns a new ListObjectChildrenPaginator 164func NewListObjectChildrenPaginator(client ListObjectChildrenAPIClient, params *ListObjectChildrenInput, optFns ...func(*ListObjectChildrenPaginatorOptions)) *ListObjectChildrenPaginator { 165 if params == nil { 166 params = &ListObjectChildrenInput{} 167 } 168 169 options := ListObjectChildrenPaginatorOptions{} 170 if params.MaxResults != nil { 171 options.Limit = *params.MaxResults 172 } 173 174 for _, fn := range optFns { 175 fn(&options) 176 } 177 178 return &ListObjectChildrenPaginator{ 179 options: options, 180 client: client, 181 params: params, 182 firstPage: true, 183 } 184} 185 186// HasMorePages returns a boolean indicating whether more pages are available 187func (p *ListObjectChildrenPaginator) HasMorePages() bool { 188 return p.firstPage || p.nextToken != nil 189} 190 191// NextPage retrieves the next ListObjectChildren page. 192func (p *ListObjectChildrenPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListObjectChildrenOutput, error) { 193 if !p.HasMorePages() { 194 return nil, fmt.Errorf("no more pages available") 195 } 196 197 params := *p.params 198 params.NextToken = p.nextToken 199 200 var limit *int32 201 if p.options.Limit > 0 { 202 limit = &p.options.Limit 203 } 204 params.MaxResults = limit 205 206 result, err := p.client.ListObjectChildren(ctx, ¶ms, optFns...) 207 if err != nil { 208 return nil, err 209 } 210 p.firstPage = false 211 212 prevToken := p.nextToken 213 p.nextToken = result.NextToken 214 215 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 216 p.nextToken = nil 217 } 218 219 return result, nil 220} 221 222func newServiceMetadataMiddleware_opListObjectChildren(region string) *awsmiddleware.RegisterServiceMetadata { 223 return &awsmiddleware.RegisterServiceMetadata{ 224 Region: region, 225 ServiceID: ServiceID, 226 SigningName: "clouddirectory", 227 OperationName: "ListObjectChildren", 228 } 229} 230