1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ec2 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/ec2/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Describes one or more flow logs. To view the information in your flow logs (the 16// log streams for the network interfaces), you must use the CloudWatch Logs 17// console or the CloudWatch Logs API. 18func (c *Client) DescribeFlowLogs(ctx context.Context, params *DescribeFlowLogsInput, optFns ...func(*Options)) (*DescribeFlowLogsOutput, error) { 19 if params == nil { 20 params = &DescribeFlowLogsInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "DescribeFlowLogs", params, optFns, addOperationDescribeFlowLogsMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*DescribeFlowLogsOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33type DescribeFlowLogsInput struct { 34 35 // Checks whether you have the required permissions for the action, without 36 // actually making the request, and provides an error response. If you have the 37 // required permissions, the error response is DryRunOperation. Otherwise, it is 38 // UnauthorizedOperation. 39 DryRun bool 40 41 // One or more filters. 42 // 43 // * deliver-log-status - The status of the logs delivery 44 // (SUCCESS | FAILED). 45 // 46 // * log-destination-type - The type of destination to which 47 // the flow log publishes data. Possible destination types include cloud-watch-logs 48 // and s3. 49 // 50 // * flow-log-id - The ID of the flow log. 51 // 52 // * log-group-name - The name of 53 // the log group. 54 // 55 // * resource-id - The ID of the VPC, subnet, or network 56 // interface. 57 // 58 // * traffic-type - The type of traffic (ACCEPT | REJECT | ALL). 59 // 60 // * 61 // tag: - The key/value combination of a tag assigned to the resource. Use the tag 62 // key in the filter name and the tag value as the filter value. For example, to 63 // find all resources that have a tag with the key Owner and the value TeamA, 64 // specify tag:Owner for the filter name and TeamA for the filter value. 65 // 66 // * tag-key 67 // - The key of a tag assigned to the resource. Use this filter to find all 68 // resources assigned a tag with a specific key, regardless of the tag value. 69 Filter []types.Filter 70 71 // One or more flow log IDs. Constraint: Maximum of 1000 flow log IDs. 72 FlowLogIds []string 73 74 // The maximum number of results to return with a single call. To retrieve the 75 // remaining results, make another call with the returned nextToken value. 76 MaxResults int32 77 78 // The token for the next page of results. 79 NextToken *string 80} 81 82type DescribeFlowLogsOutput struct { 83 84 // Information about the flow logs. 85 FlowLogs []types.FlowLog 86 87 // The token to use to retrieve the next page of results. This value is null when 88 // there are no more results to return. 89 NextToken *string 90 91 // Metadata pertaining to the operation's result. 92 ResultMetadata middleware.Metadata 93} 94 95func addOperationDescribeFlowLogsMiddlewares(stack *middleware.Stack, options Options) (err error) { 96 err = stack.Serialize.Add(&awsEc2query_serializeOpDescribeFlowLogs{}, middleware.After) 97 if err != nil { 98 return err 99 } 100 err = stack.Deserialize.Add(&awsEc2query_deserializeOpDescribeFlowLogs{}, 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 = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeFlowLogs(options.Region), middleware.Before); err != nil { 141 return err 142 } 143 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 144 return err 145 } 146 if err = addResponseErrorMiddleware(stack); err != nil { 147 return err 148 } 149 if err = addRequestResponseLogging(stack, options); err != nil { 150 return err 151 } 152 return nil 153} 154 155// DescribeFlowLogsAPIClient is a client that implements the DescribeFlowLogs 156// operation. 157type DescribeFlowLogsAPIClient interface { 158 DescribeFlowLogs(context.Context, *DescribeFlowLogsInput, ...func(*Options)) (*DescribeFlowLogsOutput, error) 159} 160 161var _ DescribeFlowLogsAPIClient = (*Client)(nil) 162 163// DescribeFlowLogsPaginatorOptions is the paginator options for DescribeFlowLogs 164type DescribeFlowLogsPaginatorOptions struct { 165 // The maximum number of results to return with a single call. To retrieve the 166 // remaining results, make another call with the returned nextToken value. 167 Limit int32 168 169 // Set to true if pagination should stop if the service returns a pagination token 170 // that matches the most recent token provided to the service. 171 StopOnDuplicateToken bool 172} 173 174// DescribeFlowLogsPaginator is a paginator for DescribeFlowLogs 175type DescribeFlowLogsPaginator struct { 176 options DescribeFlowLogsPaginatorOptions 177 client DescribeFlowLogsAPIClient 178 params *DescribeFlowLogsInput 179 nextToken *string 180 firstPage bool 181} 182 183// NewDescribeFlowLogsPaginator returns a new DescribeFlowLogsPaginator 184func NewDescribeFlowLogsPaginator(client DescribeFlowLogsAPIClient, params *DescribeFlowLogsInput, optFns ...func(*DescribeFlowLogsPaginatorOptions)) *DescribeFlowLogsPaginator { 185 options := DescribeFlowLogsPaginatorOptions{} 186 if params.MaxResults != 0 { 187 options.Limit = params.MaxResults 188 } 189 190 for _, fn := range optFns { 191 fn(&options) 192 } 193 194 if params == nil { 195 params = &DescribeFlowLogsInput{} 196 } 197 198 return &DescribeFlowLogsPaginator{ 199 options: options, 200 client: client, 201 params: params, 202 firstPage: true, 203 } 204} 205 206// HasMorePages returns a boolean indicating whether more pages are available 207func (p *DescribeFlowLogsPaginator) HasMorePages() bool { 208 return p.firstPage || p.nextToken != nil 209} 210 211// NextPage retrieves the next DescribeFlowLogs page. 212func (p *DescribeFlowLogsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeFlowLogsOutput, error) { 213 if !p.HasMorePages() { 214 return nil, fmt.Errorf("no more pages available") 215 } 216 217 params := *p.params 218 params.NextToken = p.nextToken 219 220 params.MaxResults = p.options.Limit 221 222 result, err := p.client.DescribeFlowLogs(ctx, ¶ms, optFns...) 223 if err != nil { 224 return nil, err 225 } 226 p.firstPage = false 227 228 prevToken := p.nextToken 229 p.nextToken = result.NextToken 230 231 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 232 p.nextToken = nil 233 } 234 235 return result, nil 236} 237 238func newServiceMetadataMiddleware_opDescribeFlowLogs(region string) *awsmiddleware.RegisterServiceMetadata { 239 return &awsmiddleware.RegisterServiceMetadata{ 240 Region: region, 241 ServiceID: ServiceID, 242 SigningName: "ec2", 243 OperationName: "DescribeFlowLogs", 244 } 245} 246