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// Retrieve a JSON array of up to twenty of your job templates. This will return 16// the templates themselves, not just a list of them. To retrieve the next twenty 17// templates, use the nextToken string returned with the array 18func (c *Client) ListJobTemplates(ctx context.Context, params *ListJobTemplatesInput, optFns ...func(*Options)) (*ListJobTemplatesOutput, error) { 19 if params == nil { 20 params = &ListJobTemplatesInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "ListJobTemplates", params, optFns, addOperationListJobTemplatesMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*ListJobTemplatesOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33type ListJobTemplatesInput struct { 34 35 // Optionally, specify a job template category to limit responses to only job 36 // templates from that category. 37 Category *string 38 39 // Optional. When you request a list of job templates, you can choose to list them 40 // alphabetically by NAME or chronologically by CREATION_DATE. If you don't 41 // specify, the service will list them by name. 42 ListBy types.JobTemplateListBy 43 44 // Optional. Number of job templates, up to twenty, that will be returned at one 45 // time. 46 MaxResults int32 47 48 // Use this string, provided with the response to a previous request, to request 49 // the next batch of job templates. 50 NextToken *string 51 52 // Optional. When you request lists of resources, you can specify whether they are 53 // sorted in ASCENDING or DESCENDING order. Default varies by resource. 54 Order types.Order 55} 56 57type ListJobTemplatesOutput struct { 58 59 // List of Job templates. 60 JobTemplates []types.JobTemplate 61 62 // Use this string to request the next batch of job templates. 63 NextToken *string 64 65 // Metadata pertaining to the operation's result. 66 ResultMetadata middleware.Metadata 67} 68 69func addOperationListJobTemplatesMiddlewares(stack *middleware.Stack, options Options) (err error) { 70 err = stack.Serialize.Add(&awsRestjson1_serializeOpListJobTemplates{}, middleware.After) 71 if err != nil { 72 return err 73 } 74 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListJobTemplates{}, middleware.After) 75 if err != nil { 76 return err 77 } 78 if err = addSetLoggerMiddleware(stack, options); err != nil { 79 return err 80 } 81 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 82 return err 83 } 84 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 85 return err 86 } 87 if err = addResolveEndpointMiddleware(stack, options); err != nil { 88 return err 89 } 90 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 91 return err 92 } 93 if err = addRetryMiddlewares(stack, options); err != nil { 94 return err 95 } 96 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 97 return err 98 } 99 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 100 return err 101 } 102 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 103 return err 104 } 105 if err = addClientUserAgent(stack); err != nil { 106 return err 107 } 108 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 109 return err 110 } 111 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 112 return err 113 } 114 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListJobTemplates(options.Region), middleware.Before); err != nil { 115 return err 116 } 117 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 118 return err 119 } 120 if err = addResponseErrorMiddleware(stack); err != nil { 121 return err 122 } 123 if err = addRequestResponseLogging(stack, options); err != nil { 124 return err 125 } 126 return nil 127} 128 129// ListJobTemplatesAPIClient is a client that implements the ListJobTemplates 130// operation. 131type ListJobTemplatesAPIClient interface { 132 ListJobTemplates(context.Context, *ListJobTemplatesInput, ...func(*Options)) (*ListJobTemplatesOutput, error) 133} 134 135var _ ListJobTemplatesAPIClient = (*Client)(nil) 136 137// ListJobTemplatesPaginatorOptions is the paginator options for ListJobTemplates 138type ListJobTemplatesPaginatorOptions struct { 139 // Optional. Number of job templates, up to twenty, that will be returned at one 140 // time. 141 Limit int32 142 143 // Set to true if pagination should stop if the service returns a pagination token 144 // that matches the most recent token provided to the service. 145 StopOnDuplicateToken bool 146} 147 148// ListJobTemplatesPaginator is a paginator for ListJobTemplates 149type ListJobTemplatesPaginator struct { 150 options ListJobTemplatesPaginatorOptions 151 client ListJobTemplatesAPIClient 152 params *ListJobTemplatesInput 153 nextToken *string 154 firstPage bool 155} 156 157// NewListJobTemplatesPaginator returns a new ListJobTemplatesPaginator 158func NewListJobTemplatesPaginator(client ListJobTemplatesAPIClient, params *ListJobTemplatesInput, optFns ...func(*ListJobTemplatesPaginatorOptions)) *ListJobTemplatesPaginator { 159 options := ListJobTemplatesPaginatorOptions{} 160 if params.MaxResults != 0 { 161 options.Limit = params.MaxResults 162 } 163 164 for _, fn := range optFns { 165 fn(&options) 166 } 167 168 if params == nil { 169 params = &ListJobTemplatesInput{} 170 } 171 172 return &ListJobTemplatesPaginator{ 173 options: options, 174 client: client, 175 params: params, 176 firstPage: true, 177 } 178} 179 180// HasMorePages returns a boolean indicating whether more pages are available 181func (p *ListJobTemplatesPaginator) HasMorePages() bool { 182 return p.firstPage || p.nextToken != nil 183} 184 185// NextPage retrieves the next ListJobTemplates page. 186func (p *ListJobTemplatesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListJobTemplatesOutput, error) { 187 if !p.HasMorePages() { 188 return nil, fmt.Errorf("no more pages available") 189 } 190 191 params := *p.params 192 params.NextToken = p.nextToken 193 194 params.MaxResults = p.options.Limit 195 196 result, err := p.client.ListJobTemplates(ctx, ¶ms, optFns...) 197 if err != nil { 198 return nil, err 199 } 200 p.firstPage = false 201 202 prevToken := p.nextToken 203 p.nextToken = result.NextToken 204 205 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 206 p.nextToken = nil 207 } 208 209 return result, nil 210} 211 212func newServiceMetadataMiddleware_opListJobTemplates(region string) *awsmiddleware.RegisterServiceMetadata { 213 return &awsmiddleware.RegisterServiceMetadata{ 214 Region: region, 215 ServiceID: ServiceID, 216 SigningName: "mediaconvert", 217 OperationName: "ListJobTemplates", 218 } 219} 220