1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ec2 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/ec2/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Gets usage information about a Capacity Reservation. If the Capacity Reservation 15// is shared, it shows usage information for the Capacity Reservation owner and 16// each AWS account that is currently using the shared capacity. If the Capacity 17// Reservation is not shared, it shows only the Capacity Reservation owner's usage. 18func (c *Client) GetCapacityReservationUsage(ctx context.Context, params *GetCapacityReservationUsageInput, optFns ...func(*Options)) (*GetCapacityReservationUsageOutput, error) { 19 if params == nil { 20 params = &GetCapacityReservationUsageInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "GetCapacityReservationUsage", params, optFns, addOperationGetCapacityReservationUsageMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*GetCapacityReservationUsageOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33type GetCapacityReservationUsageInput struct { 34 35 // The ID of the Capacity Reservation. 36 // 37 // This member is required. 38 CapacityReservationId *string 39 40 // Checks whether you have the required permissions for the action, without 41 // actually making the request, and provides an error response. If you have the 42 // required permissions, the error response is DryRunOperation. Otherwise, it is 43 // UnauthorizedOperation. 44 DryRun bool 45 46 // The maximum number of results to return for the request in a single page. The 47 // remaining results can be seen by sending another request with the returned 48 // nextToken value. This value can be between 5 and 500. If maxResults is given a 49 // larger value than 500, you receive an error. Valid range: Minimum value of 1. 50 // Maximum value of 1000. 51 MaxResults int32 52 53 // The token to use to retrieve the next page of results. 54 NextToken *string 55} 56 57type GetCapacityReservationUsageOutput struct { 58 59 // The remaining capacity. Indicates the number of instances that can be launched 60 // in the Capacity Reservation. 61 AvailableInstanceCount int32 62 63 // The ID of the Capacity Reservation. 64 CapacityReservationId *string 65 66 // The type of instance for which the Capacity Reservation reserves capacity. 67 InstanceType *string 68 69 // Information about the Capacity Reservation usage. 70 InstanceUsages []types.InstanceUsage 71 72 // The token to use to retrieve the next page of results. This value is null when 73 // there are no more results to return. 74 NextToken *string 75 76 // The current state of the Capacity Reservation. A Capacity Reservation can be in 77 // one of the following states: 78 // 79 // * active - The Capacity Reservation is active and 80 // the capacity is available for your use. 81 // 82 // * expired - The Capacity Reservation 83 // expired automatically at the date and time specified in your request. The 84 // reserved capacity is no longer available for your use. 85 // 86 // * cancelled - The 87 // Capacity Reservation was cancelled. The reserved capacity is no longer available 88 // for your use. 89 // 90 // * pending - The Capacity Reservation request was successful but 91 // the capacity provisioning is still pending. 92 // 93 // * failed - The Capacity Reservation 94 // request has failed. A request might fail due to invalid request parameters, 95 // capacity constraints, or instance limit constraints. Failed requests are 96 // retained for 60 minutes. 97 State types.CapacityReservationState 98 99 // The number of instances for which the Capacity Reservation reserves capacity. 100 TotalInstanceCount int32 101 102 // Metadata pertaining to the operation's result. 103 ResultMetadata middleware.Metadata 104} 105 106func addOperationGetCapacityReservationUsageMiddlewares(stack *middleware.Stack, options Options) (err error) { 107 err = stack.Serialize.Add(&awsEc2query_serializeOpGetCapacityReservationUsage{}, middleware.After) 108 if err != nil { 109 return err 110 } 111 err = stack.Deserialize.Add(&awsEc2query_deserializeOpGetCapacityReservationUsage{}, middleware.After) 112 if err != nil { 113 return err 114 } 115 if err = addSetLoggerMiddleware(stack, options); err != nil { 116 return err 117 } 118 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 119 return err 120 } 121 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 122 return err 123 } 124 if err = addResolveEndpointMiddleware(stack, options); err != nil { 125 return err 126 } 127 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 128 return err 129 } 130 if err = addRetryMiddlewares(stack, options); err != nil { 131 return err 132 } 133 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 134 return err 135 } 136 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 137 return err 138 } 139 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 140 return err 141 } 142 if err = addClientUserAgent(stack); err != nil { 143 return err 144 } 145 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 146 return err 147 } 148 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 149 return err 150 } 151 if err = addOpGetCapacityReservationUsageValidationMiddleware(stack); err != nil { 152 return err 153 } 154 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCapacityReservationUsage(options.Region), middleware.Before); err != nil { 155 return err 156 } 157 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 158 return err 159 } 160 if err = addResponseErrorMiddleware(stack); err != nil { 161 return err 162 } 163 if err = addRequestResponseLogging(stack, options); err != nil { 164 return err 165 } 166 return nil 167} 168 169func newServiceMetadataMiddleware_opGetCapacityReservationUsage(region string) *awsmiddleware.RegisterServiceMetadata { 170 return &awsmiddleware.RegisterServiceMetadata{ 171 Region: region, 172 ServiceID: ServiceID, 173 SigningName: "ec2", 174 OperationName: "GetCapacityReservationUsage", 175 } 176} 177