1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package health 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/health/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Returns a list of accounts in the organization from AWS Organizations that are 16// affected by the provided event. For more information about the different types 17// of AWS Health events, see Event 18// (https://docs.aws.amazon.com/health/latest/APIReference/API_Event.html). Before 19// you can call this operation, you must first enable AWS Health to work with AWS 20// Organizations. To do this, call the EnableHealthServiceAccessForOrganization 21// (https://docs.aws.amazon.com/health/latest/APIReference/API_EnableHealthServiceAccessForOrganization.html) 22// operation from your organization's management account. This API operation uses 23// pagination. Specify the nextToken parameter in the next request to return more 24// results. 25func (c *Client) DescribeAffectedAccountsForOrganization(ctx context.Context, params *DescribeAffectedAccountsForOrganizationInput, optFns ...func(*Options)) (*DescribeAffectedAccountsForOrganizationOutput, error) { 26 if params == nil { 27 params = &DescribeAffectedAccountsForOrganizationInput{} 28 } 29 30 result, metadata, err := c.invokeOperation(ctx, "DescribeAffectedAccountsForOrganization", params, optFns, addOperationDescribeAffectedAccountsForOrganizationMiddlewares) 31 if err != nil { 32 return nil, err 33 } 34 35 out := result.(*DescribeAffectedAccountsForOrganizationOutput) 36 out.ResultMetadata = metadata 37 return out, nil 38} 39 40type DescribeAffectedAccountsForOrganizationInput struct { 41 42 // The unique identifier for the event. The event ARN has the 43 // arn:aws:health:event-region::event/SERVICE/EVENT_TYPE_CODE/EVENT_TYPE_PLUS_ID 44 // format. For example, an event ARN might look like the following: 45 // arn:aws:health:us-east-1::event/EC2/EC2_INSTANCE_RETIREMENT_SCHEDULED/EC2_INSTANCE_RETIREMENT_SCHEDULED_ABC123-DEF456 46 // 47 // This member is required. 48 EventArn *string 49 50 // The maximum number of items to return in one batch, between 10 and 100, 51 // inclusive. 52 MaxResults *int32 53 54 // If the results of a search are large, only a portion of the results are 55 // returned, and a nextToken pagination token is returned in the response. To 56 // retrieve the next batch of results, reissue the search request and include the 57 // returned token. When all results have been returned, the response does not 58 // contain a pagination token value. 59 NextToken *string 60} 61 62type DescribeAffectedAccountsForOrganizationOutput struct { 63 64 // A JSON set of elements of the affected accounts. 65 AffectedAccounts []string 66 67 // This parameter specifies if the AWS Health event is a public AWS service event 68 // or an account-specific event. 69 // 70 // * If the eventScopeCode value is PUBLIC, then the 71 // affectedAccounts value is always empty. 72 // 73 // * If the eventScopeCode value is 74 // ACCOUNT_SPECIFIC, then the affectedAccounts value lists the affected AWS 75 // accounts in your organization. For example, if an event affects a service such 76 // as Amazon Elastic Compute Cloud and you have AWS accounts that use that service, 77 // those account IDs appear in the response. 78 // 79 // * If the eventScopeCode value is 80 // NONE, then the eventArn that you specified in the request is invalid or doesn't 81 // exist. 82 EventScopeCode types.EventScopeCode 83 84 // If the results of a search are large, only a portion of the results are 85 // returned, and a nextToken pagination token is returned in the response. To 86 // retrieve the next batch of results, reissue the search request and include the 87 // returned token. When all results have been returned, the response does not 88 // contain a pagination token value. 89 NextToken *string 90 91 // Metadata pertaining to the operation's result. 92 ResultMetadata middleware.Metadata 93} 94 95func addOperationDescribeAffectedAccountsForOrganizationMiddlewares(stack *middleware.Stack, options Options) (err error) { 96 err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeAffectedAccountsForOrganization{}, middleware.After) 97 if err != nil { 98 return err 99 } 100 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeAffectedAccountsForOrganization{}, middleware.After) 101 if err != nil { 102 return err 103 } 104 if err = addSetLoggerMiddleware(stack, options); err != nil { 105 return err 106 } 107 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 108 return err 109 } 110 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 111 return err 112 } 113 if err = addResolveEndpointMiddleware(stack, options); err != nil { 114 return err 115 } 116 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 117 return err 118 } 119 if err = addRetryMiddlewares(stack, options); err != nil { 120 return err 121 } 122 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 123 return err 124 } 125 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 126 return err 127 } 128 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 129 return err 130 } 131 if err = addClientUserAgent(stack); err != nil { 132 return err 133 } 134 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 135 return err 136 } 137 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 138 return err 139 } 140 if err = addOpDescribeAffectedAccountsForOrganizationValidationMiddleware(stack); err != nil { 141 return err 142 } 143 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeAffectedAccountsForOrganization(options.Region), middleware.Before); err != nil { 144 return err 145 } 146 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 147 return err 148 } 149 if err = addResponseErrorMiddleware(stack); err != nil { 150 return err 151 } 152 if err = addRequestResponseLogging(stack, options); err != nil { 153 return err 154 } 155 return nil 156} 157 158// DescribeAffectedAccountsForOrganizationAPIClient is a client that implements the 159// DescribeAffectedAccountsForOrganization operation. 160type DescribeAffectedAccountsForOrganizationAPIClient interface { 161 DescribeAffectedAccountsForOrganization(context.Context, *DescribeAffectedAccountsForOrganizationInput, ...func(*Options)) (*DescribeAffectedAccountsForOrganizationOutput, error) 162} 163 164var _ DescribeAffectedAccountsForOrganizationAPIClient = (*Client)(nil) 165 166// DescribeAffectedAccountsForOrganizationPaginatorOptions is the paginator options 167// for DescribeAffectedAccountsForOrganization 168type DescribeAffectedAccountsForOrganizationPaginatorOptions struct { 169 // The maximum number of items to return in one batch, between 10 and 100, 170 // inclusive. 171 Limit int32 172 173 // Set to true if pagination should stop if the service returns a pagination token 174 // that matches the most recent token provided to the service. 175 StopOnDuplicateToken bool 176} 177 178// DescribeAffectedAccountsForOrganizationPaginator is a paginator for 179// DescribeAffectedAccountsForOrganization 180type DescribeAffectedAccountsForOrganizationPaginator struct { 181 options DescribeAffectedAccountsForOrganizationPaginatorOptions 182 client DescribeAffectedAccountsForOrganizationAPIClient 183 params *DescribeAffectedAccountsForOrganizationInput 184 nextToken *string 185 firstPage bool 186} 187 188// NewDescribeAffectedAccountsForOrganizationPaginator returns a new 189// DescribeAffectedAccountsForOrganizationPaginator 190func NewDescribeAffectedAccountsForOrganizationPaginator(client DescribeAffectedAccountsForOrganizationAPIClient, params *DescribeAffectedAccountsForOrganizationInput, optFns ...func(*DescribeAffectedAccountsForOrganizationPaginatorOptions)) *DescribeAffectedAccountsForOrganizationPaginator { 191 if params == nil { 192 params = &DescribeAffectedAccountsForOrganizationInput{} 193 } 194 195 options := DescribeAffectedAccountsForOrganizationPaginatorOptions{} 196 if params.MaxResults != nil { 197 options.Limit = *params.MaxResults 198 } 199 200 for _, fn := range optFns { 201 fn(&options) 202 } 203 204 return &DescribeAffectedAccountsForOrganizationPaginator{ 205 options: options, 206 client: client, 207 params: params, 208 firstPage: true, 209 } 210} 211 212// HasMorePages returns a boolean indicating whether more pages are available 213func (p *DescribeAffectedAccountsForOrganizationPaginator) HasMorePages() bool { 214 return p.firstPage || p.nextToken != nil 215} 216 217// NextPage retrieves the next DescribeAffectedAccountsForOrganization page. 218func (p *DescribeAffectedAccountsForOrganizationPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeAffectedAccountsForOrganizationOutput, error) { 219 if !p.HasMorePages() { 220 return nil, fmt.Errorf("no more pages available") 221 } 222 223 params := *p.params 224 params.NextToken = p.nextToken 225 226 var limit *int32 227 if p.options.Limit > 0 { 228 limit = &p.options.Limit 229 } 230 params.MaxResults = limit 231 232 result, err := p.client.DescribeAffectedAccountsForOrganization(ctx, ¶ms, optFns...) 233 if err != nil { 234 return nil, err 235 } 236 p.firstPage = false 237 238 prevToken := p.nextToken 239 p.nextToken = result.NextToken 240 241 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 242 p.nextToken = nil 243 } 244 245 return result, nil 246} 247 248func newServiceMetadataMiddleware_opDescribeAffectedAccountsForOrganization(region string) *awsmiddleware.RegisterServiceMetadata { 249 return &awsmiddleware.RegisterServiceMetadata{ 250 Region: region, 251 ServiceID: ServiceID, 252 SigningName: "health", 253 OperationName: "DescribeAffectedAccountsForOrganization", 254 } 255} 256