1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package codedeploy 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/codedeploy/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// The newer BatchGetDeploymentTargets should be used instead because it works with 16// all compute types. ListDeploymentInstances throws an exception if it is used 17// with a compute platform other than EC2/On-premises or AWS Lambda. Lists the 18// instance for a deployment associated with the IAM user or AWS account. 19// 20// Deprecated: This operation is deprecated, use ListDeploymentTargets instead. 21func (c *Client) ListDeploymentInstances(ctx context.Context, params *ListDeploymentInstancesInput, optFns ...func(*Options)) (*ListDeploymentInstancesOutput, error) { 22 if params == nil { 23 params = &ListDeploymentInstancesInput{} 24 } 25 26 result, metadata, err := c.invokeOperation(ctx, "ListDeploymentInstances", params, optFns, addOperationListDeploymentInstancesMiddlewares) 27 if err != nil { 28 return nil, err 29 } 30 31 out := result.(*ListDeploymentInstancesOutput) 32 out.ResultMetadata = metadata 33 return out, nil 34} 35 36// Represents the input of a ListDeploymentInstances operation. 37type ListDeploymentInstancesInput struct { 38 39 // The unique ID of a deployment. 40 // 41 // This member is required. 42 DeploymentId *string 43 44 // A subset of instances to list by status: 45 // 46 // * Pending: Include those instances 47 // with pending deployments. 48 // 49 // * InProgress: Include those instances where 50 // deployments are still in progress. 51 // 52 // * Succeeded: Include those instances with 53 // successful deployments. 54 // 55 // * Failed: Include those instances with failed 56 // deployments. 57 // 58 // * Skipped: Include those instances with skipped deployments. 59 // 60 // * 61 // Unknown: Include those instances with deployments in an unknown state. 62 InstanceStatusFilter []types.InstanceStatus 63 64 // The set of instances in a blue/green deployment, either those in the original 65 // environment ("BLUE") or those in the replacement environment ("GREEN"), for 66 // which you want to view instance information. 67 InstanceTypeFilter []types.InstanceType 68 69 // An identifier returned from the previous list deployment instances call. It can 70 // be used to return the next set of deployment instances in the list. 71 NextToken *string 72} 73 74// Represents the output of a ListDeploymentInstances operation. 75type ListDeploymentInstancesOutput struct { 76 77 // A list of instance IDs. 78 InstancesList []string 79 80 // If a large amount of information is returned, an identifier is also returned. It 81 // can be used in a subsequent list deployment instances call to return the next 82 // set of deployment instances in the list. 83 NextToken *string 84 85 // Metadata pertaining to the operation's result. 86 ResultMetadata middleware.Metadata 87} 88 89func addOperationListDeploymentInstancesMiddlewares(stack *middleware.Stack, options Options) (err error) { 90 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListDeploymentInstances{}, middleware.After) 91 if err != nil { 92 return err 93 } 94 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListDeploymentInstances{}, middleware.After) 95 if err != nil { 96 return err 97 } 98 if err = addSetLoggerMiddleware(stack, options); err != nil { 99 return err 100 } 101 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 102 return err 103 } 104 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 105 return err 106 } 107 if err = addResolveEndpointMiddleware(stack, options); err != nil { 108 return err 109 } 110 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 111 return err 112 } 113 if err = addRetryMiddlewares(stack, options); err != nil { 114 return err 115 } 116 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 117 return err 118 } 119 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 120 return err 121 } 122 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 123 return err 124 } 125 if err = addClientUserAgent(stack); err != nil { 126 return err 127 } 128 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 129 return err 130 } 131 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 132 return err 133 } 134 if err = addOpListDeploymentInstancesValidationMiddleware(stack); err != nil { 135 return err 136 } 137 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListDeploymentInstances(options.Region), middleware.Before); err != nil { 138 return err 139 } 140 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 141 return err 142 } 143 if err = addResponseErrorMiddleware(stack); err != nil { 144 return err 145 } 146 if err = addRequestResponseLogging(stack, options); err != nil { 147 return err 148 } 149 return nil 150} 151 152// ListDeploymentInstancesAPIClient is a client that implements the 153// ListDeploymentInstances operation. 154type ListDeploymentInstancesAPIClient interface { 155 ListDeploymentInstances(context.Context, *ListDeploymentInstancesInput, ...func(*Options)) (*ListDeploymentInstancesOutput, error) 156} 157 158var _ ListDeploymentInstancesAPIClient = (*Client)(nil) 159 160// ListDeploymentInstancesPaginatorOptions is the paginator options for 161// ListDeploymentInstances 162type ListDeploymentInstancesPaginatorOptions struct { 163 // Set to true if pagination should stop if the service returns a pagination token 164 // that matches the most recent token provided to the service. 165 StopOnDuplicateToken bool 166} 167 168// ListDeploymentInstancesPaginator is a paginator for ListDeploymentInstances 169type ListDeploymentInstancesPaginator struct { 170 options ListDeploymentInstancesPaginatorOptions 171 client ListDeploymentInstancesAPIClient 172 params *ListDeploymentInstancesInput 173 nextToken *string 174 firstPage bool 175} 176 177// NewListDeploymentInstancesPaginator returns a new 178// ListDeploymentInstancesPaginator 179func NewListDeploymentInstancesPaginator(client ListDeploymentInstancesAPIClient, params *ListDeploymentInstancesInput, optFns ...func(*ListDeploymentInstancesPaginatorOptions)) *ListDeploymentInstancesPaginator { 180 if params == nil { 181 params = &ListDeploymentInstancesInput{} 182 } 183 184 options := ListDeploymentInstancesPaginatorOptions{} 185 186 for _, fn := range optFns { 187 fn(&options) 188 } 189 190 return &ListDeploymentInstancesPaginator{ 191 options: options, 192 client: client, 193 params: params, 194 firstPage: true, 195 } 196} 197 198// HasMorePages returns a boolean indicating whether more pages are available 199func (p *ListDeploymentInstancesPaginator) HasMorePages() bool { 200 return p.firstPage || p.nextToken != nil 201} 202 203// NextPage retrieves the next ListDeploymentInstances page. 204func (p *ListDeploymentInstancesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListDeploymentInstancesOutput, error) { 205 if !p.HasMorePages() { 206 return nil, fmt.Errorf("no more pages available") 207 } 208 209 params := *p.params 210 params.NextToken = p.nextToken 211 212 result, err := p.client.ListDeploymentInstances(ctx, ¶ms, optFns...) 213 if err != nil { 214 return nil, err 215 } 216 p.firstPage = false 217 218 prevToken := p.nextToken 219 p.nextToken = result.NextToken 220 221 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 222 p.nextToken = nil 223 } 224 225 return result, nil 226} 227 228func newServiceMetadataMiddleware_opListDeploymentInstances(region string) *awsmiddleware.RegisterServiceMetadata { 229 return &awsmiddleware.RegisterServiceMetadata{ 230 Region: region, 231 ServiceID: ServiceID, 232 SigningName: "codedeploy", 233 OperationName: "ListDeploymentInstances", 234 } 235} 236