1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package mediaconvert 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/mediaconvert/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Send an request with an empty body to the regional API endpoint to get your 16// account API endpoint. 17func (c *Client) DescribeEndpoints(ctx context.Context, params *DescribeEndpointsInput, optFns ...func(*Options)) (*DescribeEndpointsOutput, error) { 18 if params == nil { 19 params = &DescribeEndpointsInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "DescribeEndpoints", params, optFns, addOperationDescribeEndpointsMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*DescribeEndpointsOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32// DescribeEndpointsRequest 33type DescribeEndpointsInput struct { 34 35 // Optional. Max number of endpoints, up to twenty, that will be returned at one 36 // time. 37 MaxResults int32 38 39 // Optional field, defaults to DEFAULT. Specify DEFAULT for this operation to 40 // return your endpoints if any exist, or to create an endpoint for you and return 41 // it if one doesn't already exist. Specify GET_ONLY to return your endpoints if 42 // any exist, or an empty list if none exist. 43 Mode types.DescribeEndpointsMode 44 45 // Use this string, provided with the response to a previous request, to request 46 // the next batch of endpoints. 47 NextToken *string 48} 49 50type DescribeEndpointsOutput struct { 51 52 // List of endpoints 53 Endpoints []types.Endpoint 54 55 // Use this string to request the next batch of endpoints. 56 NextToken *string 57 58 // Metadata pertaining to the operation's result. 59 ResultMetadata middleware.Metadata 60} 61 62func addOperationDescribeEndpointsMiddlewares(stack *middleware.Stack, options Options) (err error) { 63 err = stack.Serialize.Add(&awsRestjson1_serializeOpDescribeEndpoints{}, middleware.After) 64 if err != nil { 65 return err 66 } 67 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpDescribeEndpoints{}, middleware.After) 68 if err != nil { 69 return err 70 } 71 if err = addSetLoggerMiddleware(stack, options); err != nil { 72 return err 73 } 74 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 75 return err 76 } 77 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 78 return err 79 } 80 if err = addResolveEndpointMiddleware(stack, options); err != nil { 81 return err 82 } 83 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 84 return err 85 } 86 if err = addRetryMiddlewares(stack, options); err != nil { 87 return err 88 } 89 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 90 return err 91 } 92 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 93 return err 94 } 95 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 96 return err 97 } 98 if err = addClientUserAgent(stack); err != nil { 99 return err 100 } 101 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 102 return err 103 } 104 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 105 return err 106 } 107 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeEndpoints(options.Region), middleware.Before); err != nil { 108 return err 109 } 110 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 111 return err 112 } 113 if err = addResponseErrorMiddleware(stack); err != nil { 114 return err 115 } 116 if err = addRequestResponseLogging(stack, options); err != nil { 117 return err 118 } 119 return nil 120} 121 122// DescribeEndpointsAPIClient is a client that implements the DescribeEndpoints 123// operation. 124type DescribeEndpointsAPIClient interface { 125 DescribeEndpoints(context.Context, *DescribeEndpointsInput, ...func(*Options)) (*DescribeEndpointsOutput, error) 126} 127 128var _ DescribeEndpointsAPIClient = (*Client)(nil) 129 130// DescribeEndpointsPaginatorOptions is the paginator options for DescribeEndpoints 131type DescribeEndpointsPaginatorOptions struct { 132 // Optional. Max number of endpoints, up to twenty, that will be returned at one 133 // time. 134 Limit int32 135 136 // Set to true if pagination should stop if the service returns a pagination token 137 // that matches the most recent token provided to the service. 138 StopOnDuplicateToken bool 139} 140 141// DescribeEndpointsPaginator is a paginator for DescribeEndpoints 142type DescribeEndpointsPaginator struct { 143 options DescribeEndpointsPaginatorOptions 144 client DescribeEndpointsAPIClient 145 params *DescribeEndpointsInput 146 nextToken *string 147 firstPage bool 148} 149 150// NewDescribeEndpointsPaginator returns a new DescribeEndpointsPaginator 151func NewDescribeEndpointsPaginator(client DescribeEndpointsAPIClient, params *DescribeEndpointsInput, optFns ...func(*DescribeEndpointsPaginatorOptions)) *DescribeEndpointsPaginator { 152 if params == nil { 153 params = &DescribeEndpointsInput{} 154 } 155 156 options := DescribeEndpointsPaginatorOptions{} 157 if params.MaxResults != 0 { 158 options.Limit = params.MaxResults 159 } 160 161 for _, fn := range optFns { 162 fn(&options) 163 } 164 165 return &DescribeEndpointsPaginator{ 166 options: options, 167 client: client, 168 params: params, 169 firstPage: true, 170 } 171} 172 173// HasMorePages returns a boolean indicating whether more pages are available 174func (p *DescribeEndpointsPaginator) HasMorePages() bool { 175 return p.firstPage || p.nextToken != nil 176} 177 178// NextPage retrieves the next DescribeEndpoints page. 179func (p *DescribeEndpointsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeEndpointsOutput, error) { 180 if !p.HasMorePages() { 181 return nil, fmt.Errorf("no more pages available") 182 } 183 184 params := *p.params 185 params.NextToken = p.nextToken 186 187 params.MaxResults = p.options.Limit 188 189 result, err := p.client.DescribeEndpoints(ctx, ¶ms, optFns...) 190 if err != nil { 191 return nil, err 192 } 193 p.firstPage = false 194 195 prevToken := p.nextToken 196 p.nextToken = result.NextToken 197 198 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 199 p.nextToken = nil 200 } 201 202 return result, nil 203} 204 205func newServiceMetadataMiddleware_opDescribeEndpoints(region string) *awsmiddleware.RegisterServiceMetadata { 206 return &awsmiddleware.RegisterServiceMetadata{ 207 Region: region, 208 ServiceID: ServiceID, 209 SigningName: "mediaconvert", 210 OperationName: "DescribeEndpoints", 211 } 212} 213