github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/secrets/secrets_client/keys/save_keypair_parameters.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  	"net/http"
    10  	"time"
    11  
    12  	"golang.org/x/net/context"
    13  
    14  	"github.com/go-openapi/errors"
    15  	"github.com/go-openapi/runtime"
    16  	cr "github.com/go-openapi/runtime/client"
    17  
    18  	strfmt "github.com/go-openapi/strfmt"
    19  
    20  	secrets_models "github.com/ActiveState/cli/pkg/platform/api/secrets/secrets_models"
    21  )
    22  
    23  // NewSaveKeypairParams creates a new SaveKeypairParams object
    24  // with the default values initialized.
    25  func NewSaveKeypairParams() *SaveKeypairParams {
    26  	var ()
    27  	return &SaveKeypairParams{
    28  
    29  		timeout: cr.DefaultTimeout,
    30  	}
    31  }
    32  
    33  // NewSaveKeypairParamsWithTimeout creates a new SaveKeypairParams object
    34  // with the default values initialized, and the ability to set a timeout on a request
    35  func NewSaveKeypairParamsWithTimeout(timeout time.Duration) *SaveKeypairParams {
    36  	var ()
    37  	return &SaveKeypairParams{
    38  
    39  		timeout: timeout,
    40  	}
    41  }
    42  
    43  // NewSaveKeypairParamsWithContext creates a new SaveKeypairParams object
    44  // with the default values initialized, and the ability to set a context for a request
    45  func NewSaveKeypairParamsWithContext(ctx context.Context) *SaveKeypairParams {
    46  	var ()
    47  	return &SaveKeypairParams{
    48  
    49  		Context: ctx,
    50  	}
    51  }
    52  
    53  // NewSaveKeypairParamsWithHTTPClient creates a new SaveKeypairParams object
    54  // with the default values initialized, and the ability to set a custom HTTPClient for a request
    55  func NewSaveKeypairParamsWithHTTPClient(client *http.Client) *SaveKeypairParams {
    56  	var ()
    57  	return &SaveKeypairParams{
    58  		HTTPClient: client,
    59  	}
    60  }
    61  
    62  /*SaveKeypairParams contains all the parameters to send to the API endpoint
    63  for the save keypair operation typically these are written to a http.Request
    64  */
    65  type SaveKeypairParams struct {
    66  
    67  	/*Keypair
    68  	  Keypair to create or update
    69  
    70  	*/
    71  	Keypair *secrets_models.KeypairChange
    72  
    73  	timeout    time.Duration
    74  	Context    context.Context
    75  	HTTPClient *http.Client
    76  }
    77  
    78  // WithTimeout adds the timeout to the save keypair params
    79  func (o *SaveKeypairParams) WithTimeout(timeout time.Duration) *SaveKeypairParams {
    80  	o.SetTimeout(timeout)
    81  	return o
    82  }
    83  
    84  // SetTimeout adds the timeout to the save keypair params
    85  func (o *SaveKeypairParams) SetTimeout(timeout time.Duration) {
    86  	o.timeout = timeout
    87  }
    88  
    89  // WithContext adds the context to the save keypair params
    90  func (o *SaveKeypairParams) WithContext(ctx context.Context) *SaveKeypairParams {
    91  	o.SetContext(ctx)
    92  	return o
    93  }
    94  
    95  // SetContext adds the context to the save keypair params
    96  func (o *SaveKeypairParams) SetContext(ctx context.Context) {
    97  	o.Context = ctx
    98  }
    99  
   100  // WithHTTPClient adds the HTTPClient to the save keypair params
   101  func (o *SaveKeypairParams) WithHTTPClient(client *http.Client) *SaveKeypairParams {
   102  	o.SetHTTPClient(client)
   103  	return o
   104  }
   105  
   106  // SetHTTPClient adds the HTTPClient to the save keypair params
   107  func (o *SaveKeypairParams) SetHTTPClient(client *http.Client) {
   108  	o.HTTPClient = client
   109  }
   110  
   111  // WithKeypair adds the keypair to the save keypair params
   112  func (o *SaveKeypairParams) WithKeypair(keypair *secrets_models.KeypairChange) *SaveKeypairParams {
   113  	o.SetKeypair(keypair)
   114  	return o
   115  }
   116  
   117  // SetKeypair adds the keypair to the save keypair params
   118  func (o *SaveKeypairParams) SetKeypair(keypair *secrets_models.KeypairChange) {
   119  	o.Keypair = keypair
   120  }
   121  
   122  // WriteToRequest writes these params to a swagger request
   123  func (o *SaveKeypairParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   124  
   125  	if err := r.SetTimeout(o.timeout); err != nil {
   126  		return err
   127  	}
   128  	var res []error
   129  
   130  	if o.Keypair != nil {
   131  		if err := r.SetBodyParam(o.Keypair); err != nil {
   132  			return err
   133  		}
   134  	}
   135  
   136  	if len(res) > 0 {
   137  		return errors.CompositeValidationError(res...)
   138  	}
   139  	return nil
   140  }