github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/secrets/secrets_client/keys/keys_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package keys
     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  	"github.com/ActiveState/cli/internal/errs"
    10  	"github.com/go-openapi/runtime"
    11  
    12  	"github.com/go-openapi/strfmt"
    13  )
    14  
    15  // New creates a new keys API client.
    16  func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client {
    17  	return &Client{transport: transport, formats: formats}
    18  }
    19  
    20  /*
    21  Client for keys API
    22  */
    23  type Client struct {
    24  	transport runtime.ClientTransport
    25  	formats   strfmt.Registry
    26  }
    27  
    28  /*
    29  GetKeypair gets authenticated user s keypair
    30  
    31  Get authenticated user's keypair
    32  */
    33  func (a *Client) GetKeypair(params *GetKeypairParams, authInfo runtime.ClientAuthInfoWriter) (*GetKeypairOK, error) {
    34  	// TODO: Validate the params before sending
    35  	if params == nil {
    36  		params = NewGetKeypairParams()
    37  	}
    38  
    39  	result, err := a.transport.Submit(&runtime.ClientOperation{
    40  		ID:                 "getKeypair",
    41  		Method:             "GET",
    42  		PathPattern:        "/keypair",
    43  		ProducesMediaTypes: []string{"application/json"},
    44  		ConsumesMediaTypes: []string{"application/json"},
    45  		Schemes:            []string{"http"},
    46  		Params:             params,
    47  		Reader:             &GetKeypairReader{formats: a.formats},
    48  		AuthInfo:           authInfo,
    49  		Context:            params.Context,
    50  		Client:             params.HTTPClient,
    51  	})
    52  	if err != nil {
    53  		return nil, err
    54  	}
    55  	return result.(*GetKeypairOK), nil
    56  
    57  }
    58  
    59  /*
    60  GetPublicKey gets a specific user s public key
    61  
    62  Get a specific user's public-key
    63  */
    64  func (a *Client) GetPublicKey(params *GetPublicKeyParams, authInfo runtime.ClientAuthInfoWriter) (*GetPublicKeyOK, error) {
    65  	// TODO: Validate the params before sending
    66  	if params == nil {
    67  		params = NewGetPublicKeyParams()
    68  	}
    69  
    70  	result, err := a.transport.Submit(&runtime.ClientOperation{
    71  		ID:                 "getPublicKey",
    72  		Method:             "GET",
    73  		PathPattern:        "/publickeys/{userID}",
    74  		ProducesMediaTypes: []string{"application/json"},
    75  		ConsumesMediaTypes: []string{"application/json"},
    76  		Schemes:            []string{"http"},
    77  		Params:             params,
    78  		Reader:             &GetPublicKeyReader{formats: a.formats},
    79  		AuthInfo:           authInfo,
    80  		Context:            params.Context,
    81  		Client:             params.HTTPClient,
    82  	})
    83  	if err != nil {
    84  		return nil, err
    85  	}
    86  	return result.(*GetPublicKeyOK), nil
    87  
    88  }
    89  
    90  /*
    91  SaveKeypair creates or update a current user s keypair
    92  
    93  Create or update current user's keypair
    94  */
    95  func (a *Client) SaveKeypair(params *SaveKeypairParams, authInfo runtime.ClientAuthInfoWriter) (*SaveKeypairNoContent, error) {
    96  	// TODO: Validate the params before sending
    97  	if params == nil {
    98  		params = NewSaveKeypairParams()
    99  	}
   100  
   101  	result, err := a.transport.Submit(&runtime.ClientOperation{
   102  		ID:                 "saveKeypair",
   103  		Method:             "PUT",
   104  		PathPattern:        "/keypair",
   105  		ProducesMediaTypes: []string{"application/json"},
   106  		ConsumesMediaTypes: []string{"application/json"},
   107  		Schemes:            []string{"http"},
   108  		Params:             params,
   109  		Reader:             &SaveKeypairReader{formats: a.formats},
   110  		AuthInfo:           authInfo,
   111  		Context:            params.Context,
   112  		Client:             params.HTTPClient,
   113  	})
   114  	if err != nil {
   115  		return nil, errs.Wrap(err, "Could not save client-side encrypted keypair to platform.")
   116  	}
   117  	return result.(*SaveKeypairNoContent), nil
   118  
   119  }
   120  
   121  // SetTransport changes the transport on the client
   122  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   123  	a.transport = transport
   124  }