1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package servicecatalog 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/servicecatalog/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Returns a summary of each of the portfolio shares that were created for the 16// specified portfolio. You can use this API to determine which accounts or 17// organizational nodes this portfolio have been shared, whether the recipient 18// entity has imported the share, and whether TagOptions are included with the 19// share. The PortfolioId and Type parameters are both required. 20func (c *Client) DescribePortfolioShares(ctx context.Context, params *DescribePortfolioSharesInput, optFns ...func(*Options)) (*DescribePortfolioSharesOutput, error) { 21 if params == nil { 22 params = &DescribePortfolioSharesInput{} 23 } 24 25 result, metadata, err := c.invokeOperation(ctx, "DescribePortfolioShares", params, optFns, addOperationDescribePortfolioSharesMiddlewares) 26 if err != nil { 27 return nil, err 28 } 29 30 out := result.(*DescribePortfolioSharesOutput) 31 out.ResultMetadata = metadata 32 return out, nil 33} 34 35type DescribePortfolioSharesInput struct { 36 37 // The unique identifier of the portfolio for which shares will be retrieved. 38 // 39 // This member is required. 40 PortfolioId *string 41 42 // The type of portfolio share to summarize. This field acts as a filter on the 43 // type of portfolio share, which can be one of the following: 1. ACCOUNT - 44 // Represents an external account to account share. 2. ORGANIZATION - Represents a 45 // share to an organization. This share is available to every account in the 46 // organization. 3. ORGANIZATIONAL_UNIT - Represents a share to an organizational 47 // unit. 4. ORGANIZATION_MEMBER_ACCOUNT - Represents a share to an account in the 48 // organization. 49 // 50 // This member is required. 51 Type types.DescribePortfolioShareType 52 53 // The maximum number of items to return with this call. 54 PageSize int32 55 56 // The page token for the next set of results. To retrieve the first set of 57 // results, use null. 58 PageToken *string 59} 60 61type DescribePortfolioSharesOutput struct { 62 63 // The page token to use to retrieve the next set of results. If there are no 64 // additional results, this value is null. 65 NextPageToken *string 66 67 // Summaries about each of the portfolio shares. 68 PortfolioShareDetails []types.PortfolioShareDetail 69 70 // Metadata pertaining to the operation's result. 71 ResultMetadata middleware.Metadata 72} 73 74func addOperationDescribePortfolioSharesMiddlewares(stack *middleware.Stack, options Options) (err error) { 75 err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribePortfolioShares{}, middleware.After) 76 if err != nil { 77 return err 78 } 79 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribePortfolioShares{}, middleware.After) 80 if err != nil { 81 return err 82 } 83 if err = addSetLoggerMiddleware(stack, options); err != nil { 84 return err 85 } 86 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 87 return err 88 } 89 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 90 return err 91 } 92 if err = addResolveEndpointMiddleware(stack, options); err != nil { 93 return err 94 } 95 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 96 return err 97 } 98 if err = addRetryMiddlewares(stack, options); err != nil { 99 return err 100 } 101 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 102 return err 103 } 104 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 105 return err 106 } 107 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 108 return err 109 } 110 if err = addClientUserAgent(stack); err != nil { 111 return err 112 } 113 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 114 return err 115 } 116 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 117 return err 118 } 119 if err = addOpDescribePortfolioSharesValidationMiddleware(stack); err != nil { 120 return err 121 } 122 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribePortfolioShares(options.Region), middleware.Before); err != nil { 123 return err 124 } 125 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 126 return err 127 } 128 if err = addResponseErrorMiddleware(stack); err != nil { 129 return err 130 } 131 if err = addRequestResponseLogging(stack, options); err != nil { 132 return err 133 } 134 return nil 135} 136 137// DescribePortfolioSharesAPIClient is a client that implements the 138// DescribePortfolioShares operation. 139type DescribePortfolioSharesAPIClient interface { 140 DescribePortfolioShares(context.Context, *DescribePortfolioSharesInput, ...func(*Options)) (*DescribePortfolioSharesOutput, error) 141} 142 143var _ DescribePortfolioSharesAPIClient = (*Client)(nil) 144 145// DescribePortfolioSharesPaginatorOptions is the paginator options for 146// DescribePortfolioShares 147type DescribePortfolioSharesPaginatorOptions struct { 148 // The maximum number of items to return with this call. 149 Limit int32 150 151 // Set to true if pagination should stop if the service returns a pagination token 152 // that matches the most recent token provided to the service. 153 StopOnDuplicateToken bool 154} 155 156// DescribePortfolioSharesPaginator is a paginator for DescribePortfolioShares 157type DescribePortfolioSharesPaginator struct { 158 options DescribePortfolioSharesPaginatorOptions 159 client DescribePortfolioSharesAPIClient 160 params *DescribePortfolioSharesInput 161 nextToken *string 162 firstPage bool 163} 164 165// NewDescribePortfolioSharesPaginator returns a new 166// DescribePortfolioSharesPaginator 167func NewDescribePortfolioSharesPaginator(client DescribePortfolioSharesAPIClient, params *DescribePortfolioSharesInput, optFns ...func(*DescribePortfolioSharesPaginatorOptions)) *DescribePortfolioSharesPaginator { 168 options := DescribePortfolioSharesPaginatorOptions{} 169 if params.PageSize != 0 { 170 options.Limit = params.PageSize 171 } 172 173 for _, fn := range optFns { 174 fn(&options) 175 } 176 177 if params == nil { 178 params = &DescribePortfolioSharesInput{} 179 } 180 181 return &DescribePortfolioSharesPaginator{ 182 options: options, 183 client: client, 184 params: params, 185 firstPage: true, 186 } 187} 188 189// HasMorePages returns a boolean indicating whether more pages are available 190func (p *DescribePortfolioSharesPaginator) HasMorePages() bool { 191 return p.firstPage || p.nextToken != nil 192} 193 194// NextPage retrieves the next DescribePortfolioShares page. 195func (p *DescribePortfolioSharesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribePortfolioSharesOutput, error) { 196 if !p.HasMorePages() { 197 return nil, fmt.Errorf("no more pages available") 198 } 199 200 params := *p.params 201 params.PageToken = p.nextToken 202 203 params.PageSize = p.options.Limit 204 205 result, err := p.client.DescribePortfolioShares(ctx, ¶ms, optFns...) 206 if err != nil { 207 return nil, err 208 } 209 p.firstPage = false 210 211 prevToken := p.nextToken 212 p.nextToken = result.NextPageToken 213 214 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 215 p.nextToken = nil 216 } 217 218 return result, nil 219} 220 221func newServiceMetadataMiddleware_opDescribePortfolioShares(region string) *awsmiddleware.RegisterServiceMetadata { 222 return &awsmiddleware.RegisterServiceMetadata{ 223 Region: region, 224 ServiceID: ServiceID, 225 SigningName: "servicecatalog", 226 OperationName: "DescribePortfolioShares", 227 } 228} 229