github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_client/s3/s3_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package s3
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"fmt"
    10  
    11  	"github.com/go-openapi/runtime"
    12  	"github.com/go-openapi/strfmt"
    13  )
    14  
    15  // New creates a new s3 API client.
    16  func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
    17  	return &Client{transport: transport, formats: formats}
    18  }
    19  
    20  /*
    21  Client for s3 API
    22  */
    23  type Client struct {
    24  	transport runtime.ClientTransport
    25  	formats   strfmt.Registry
    26  }
    27  
    28  // ClientOption is the option for Client methods
    29  type ClientOption func(*runtime.ClientOperation)
    30  
    31  // ClientService is the interface for Client methods
    32  type ClientService interface {
    33  	SignS3URI(params *SignS3URIParams, opts ...ClientOption) (*SignS3URIOK, error)
    34  
    35  	SetTransport(transport runtime.ClientTransport)
    36  }
    37  
    38  /*
    39    SignS3URI signs an s3 URI
    40  
    41    Returns a signed, limited-duration S3 URI
    42  */
    43  func (a *Client) SignS3URI(params *SignS3URIParams, opts ...ClientOption) (*SignS3URIOK, error) {
    44  	// TODO: Validate the params before sending
    45  	if params == nil {
    46  		params = NewSignS3URIParams()
    47  	}
    48  	op := &runtime.ClientOperation{
    49  		ID:                 "signS3URI",
    50  		Method:             "GET",
    51  		PathPattern:        "/s3/sign/{URI}",
    52  		ProducesMediaTypes: []string{"application/json"},
    53  		ConsumesMediaTypes: []string{"application/json"},
    54  		Schemes:            []string{"http", "https"},
    55  		Params:             params,
    56  		Reader:             &SignS3URIReader{formats: a.formats},
    57  		Context:            params.Context,
    58  		Client:             params.HTTPClient,
    59  	}
    60  	for _, opt := range opts {
    61  		opt(op)
    62  	}
    63  
    64  	result, err := a.transport.Submit(op)
    65  	if err != nil {
    66  		return nil, err
    67  	}
    68  	success, ok := result.(*SignS3URIOK)
    69  	if ok {
    70  		return success, nil
    71  	}
    72  	// unexpected success response
    73  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    74  	msg := fmt.Sprintf("unexpected success response for signS3URI: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    75  	panic(msg)
    76  }
    77  
    78  // SetTransport changes the transport on the client
    79  func (a *Client) SetTransport(transport runtime.ClientTransport) {
    80  	a.transport = transport
    81  }