// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. package codeartifact import ( "context" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" ) type ListPackagesInput struct { _ struct{} `type:"structure"` // The domain that contains the repository that contains the requested list // of packages. // // Domain is a required field Domain *string `location:"querystring" locationName:"domain" min:"2" type:"string" required:"true"` // The 12-digit account number of the AWS account that owns the domain. It does // not include dashes or spaces. DomainOwner *string `location:"querystring" locationName:"domain-owner" min:"12" type:"string"` // The format of the packages. The valid package types are: // // * npm: A Node Package Manager (npm) package. // // * pypi: A Python Package Index (PyPI) package. // // * maven: A Maven package that contains compiled code in a distributable // format, such as a JAR file. Format PackageFormat `location:"querystring" locationName:"format" type:"string" enum:"true"` // The maximum number of results to return per page. MaxResults *int64 `location:"querystring" locationName:"max-results" min:"1" type:"integer"` // The namespace of the package. The package component that specifies its namespace // depends on its type. For example: // // * The namespace of a Maven package is its groupId. // // * The namespace of an npm package is its scope. // // * A Python package does not contain a corresponding component, so Python // packages do not have a namespace. Namespace *string `location:"querystring" locationName:"namespace" min:"1" type:"string"` // The token for the next set of results. Use the value returned in the previous // response in the next request to retrieve the next set of results. NextToken *string `location:"querystring" locationName:"next-token" min:"1" type:"string"` // A prefix used to filter returned repositories. Only repositories with names // that start with repositoryPrefix are returned. PackagePrefix *string `location:"querystring" locationName:"package-prefix" min:"1" type:"string"` // The name of the repository from which packages are to be listed. // // Repository is a required field Repository *string `location:"querystring" locationName:"repository" min:"2" type:"string" required:"true"` } // String returns the string representation func (s ListPackagesInput) String() string { return awsutil.Prettify(s) } // Validate inspects the fields of the type to determine if they are valid. func (s *ListPackagesInput) Validate() error { invalidParams := aws.ErrInvalidParams{Context: "ListPackagesInput"} if s.Domain == nil { invalidParams.Add(aws.NewErrParamRequired("Domain")) } if s.Domain != nil && len(*s.Domain) < 2 { invalidParams.Add(aws.NewErrParamMinLen("Domain", 2)) } if s.DomainOwner != nil && len(*s.DomainOwner) < 12 { invalidParams.Add(aws.NewErrParamMinLen("DomainOwner", 12)) } if s.MaxResults != nil && *s.MaxResults < 1 { invalidParams.Add(aws.NewErrParamMinValue("MaxResults", 1)) } if s.Namespace != nil && len(*s.Namespace) < 1 { invalidParams.Add(aws.NewErrParamMinLen("Namespace", 1)) } if s.NextToken != nil && len(*s.NextToken) < 1 { invalidParams.Add(aws.NewErrParamMinLen("NextToken", 1)) } if s.PackagePrefix != nil && len(*s.PackagePrefix) < 1 { invalidParams.Add(aws.NewErrParamMinLen("PackagePrefix", 1)) } if s.Repository == nil { invalidParams.Add(aws.NewErrParamRequired("Repository")) } if s.Repository != nil && len(*s.Repository) < 2 { invalidParams.Add(aws.NewErrParamMinLen("Repository", 2)) } if invalidParams.Len() > 0 { return invalidParams } return nil } // MarshalFields encodes the AWS API shape using the passed in protocol encoder. func (s ListPackagesInput) MarshalFields(e protocol.FieldEncoder) error { e.SetValue(protocol.HeaderTarget, "Content-Type", protocol.StringValue("application/json"), protocol.Metadata{}) if s.Domain != nil { v := *s.Domain metadata := protocol.Metadata{} e.SetValue(protocol.QueryTarget, "domain", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if s.DomainOwner != nil { v := *s.DomainOwner metadata := protocol.Metadata{} e.SetValue(protocol.QueryTarget, "domain-owner", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if len(s.Format) > 0 { v := s.Format metadata := protocol.Metadata{} e.SetValue(protocol.QueryTarget, "format", protocol.QuotedValue{ValueMarshaler: v}, metadata) } if s.MaxResults != nil { v := *s.MaxResults metadata := protocol.Metadata{} e.SetValue(protocol.QueryTarget, "max-results", protocol.Int64Value(v), metadata) } if s.Namespace != nil { v := *s.Namespace metadata := protocol.Metadata{} e.SetValue(protocol.QueryTarget, "namespace", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if s.NextToken != nil { v := *s.NextToken metadata := protocol.Metadata{} e.SetValue(protocol.QueryTarget, "next-token", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if s.PackagePrefix != nil { v := *s.PackagePrefix metadata := protocol.Metadata{} e.SetValue(protocol.QueryTarget, "package-prefix", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if s.Repository != nil { v := *s.Repository metadata := protocol.Metadata{} e.SetValue(protocol.QueryTarget, "repository", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } return nil } type ListPackagesOutput struct { _ struct{} `type:"structure"` // If there are additional results, this is the token for the next set of results. NextToken *string `locationName:"nextToken" min:"1" type:"string"` // The list of returned PackageSummary (https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageSummary.html) // objects. Packages []PackageSummary `locationName:"packages" type:"list"` } // String returns the string representation func (s ListPackagesOutput) String() string { return awsutil.Prettify(s) } // MarshalFields encodes the AWS API shape using the passed in protocol encoder. func (s ListPackagesOutput) MarshalFields(e protocol.FieldEncoder) error { if s.NextToken != nil { v := *s.NextToken metadata := protocol.Metadata{} e.SetValue(protocol.BodyTarget, "nextToken", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if s.Packages != nil { v := s.Packages metadata := protocol.Metadata{} ls0 := e.List(protocol.BodyTarget, "packages", metadata) ls0.Start() for _, v1 := range v { ls0.ListAddFields(v1) } ls0.End() } return nil } const opListPackages = "ListPackages" // ListPackagesRequest returns a request value for making API operation for // CodeArtifact. // // Returns a list of PackageSummary (https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_PackageSummary.html) // objects for packages in a repository that match the request parameters. // // // Example sending a request using ListPackagesRequest. // req := client.ListPackagesRequest(params) // resp, err := req.Send(context.TODO()) // if err == nil { // fmt.Println(resp) // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/codeartifact-2018-09-22/ListPackages func (c *Client) ListPackagesRequest(input *ListPackagesInput) ListPackagesRequest { op := &aws.Operation{ Name: opListPackages, HTTPMethod: "POST", HTTPPath: "/v1/packages", Paginator: &aws.Paginator{ InputTokens: []string{"nextToken"}, OutputTokens: []string{"nextToken"}, LimitToken: "maxResults", TruncationToken: "", }, } if input == nil { input = &ListPackagesInput{} } req := c.newRequest(op, input, &ListPackagesOutput{}) return ListPackagesRequest{Request: req, Input: input, Copy: c.ListPackagesRequest} } // ListPackagesRequest is the request type for the // ListPackages API operation. type ListPackagesRequest struct { *aws.Request Input *ListPackagesInput Copy func(*ListPackagesInput) ListPackagesRequest } // Send marshals and sends the ListPackages API request. func (r ListPackagesRequest) Send(ctx context.Context) (*ListPackagesResponse, error) { r.Request.SetContext(ctx) err := r.Request.Send() if err != nil { return nil, err } resp := &ListPackagesResponse{ ListPackagesOutput: r.Request.Data.(*ListPackagesOutput), response: &aws.Response{Request: r.Request}, } return resp, nil } // NewListPackagesRequestPaginator returns a paginator for ListPackages. // Use Next method to get the next page, and CurrentPage to get the current // response page from the paginator. Next will return false, if there are // no more pages, or an error was encountered. // // Note: This operation can generate multiple requests to a service. // // // Example iterating over pages. // req := client.ListPackagesRequest(input) // p := codeartifact.NewListPackagesRequestPaginator(req) // // for p.Next(context.TODO()) { // page := p.CurrentPage() // } // // if err := p.Err(); err != nil { // return err // } // func NewListPackagesPaginator(req ListPackagesRequest) ListPackagesPaginator { return ListPackagesPaginator{ Pager: aws.Pager{ NewRequest: func(ctx context.Context) (*aws.Request, error) { var inCpy *ListPackagesInput if req.Input != nil { tmp := *req.Input inCpy = &tmp } newReq := req.Copy(inCpy) newReq.SetContext(ctx) return newReq.Request, nil }, }, } } // ListPackagesPaginator is used to paginate the request. This can be done by // calling Next and CurrentPage. type ListPackagesPaginator struct { aws.Pager } func (p *ListPackagesPaginator) CurrentPage() *ListPackagesOutput { return p.Pager.CurrentPage().(*ListPackagesOutput) } // ListPackagesResponse is the response type for the // ListPackages API operation. type ListPackagesResponse struct { *ListPackagesOutput response *aws.Response } // SDKResponseMetdata returns the response metadata for the // ListPackages request. func (r *ListPackagesResponse) SDKResponseMetdata() *aws.Response { return r.response }