github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/replication/update_replication_policy_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package replication
     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  	"context"
    10  	"net/http"
    11  	"time"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/runtime"
    15  	cr "github.com/go-openapi/runtime/client"
    16  	"github.com/go-openapi/strfmt"
    17  	"github.com/go-openapi/swag"
    18  
    19  	"github.com/goharbor/go-client/pkg/sdk/v2.0/models"
    20  )
    21  
    22  // NewUpdateReplicationPolicyParams creates a new UpdateReplicationPolicyParams object,
    23  // with the default timeout for this client.
    24  //
    25  // Default values are not hydrated, since defaults are normally applied by the API server side.
    26  //
    27  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    28  func NewUpdateReplicationPolicyParams() *UpdateReplicationPolicyParams {
    29  	return &UpdateReplicationPolicyParams{
    30  		timeout: cr.DefaultTimeout,
    31  	}
    32  }
    33  
    34  // NewUpdateReplicationPolicyParamsWithTimeout creates a new UpdateReplicationPolicyParams object
    35  // with the ability to set a timeout on a request.
    36  func NewUpdateReplicationPolicyParamsWithTimeout(timeout time.Duration) *UpdateReplicationPolicyParams {
    37  	return &UpdateReplicationPolicyParams{
    38  		timeout: timeout,
    39  	}
    40  }
    41  
    42  // NewUpdateReplicationPolicyParamsWithContext creates a new UpdateReplicationPolicyParams object
    43  // with the ability to set a context for a request.
    44  func NewUpdateReplicationPolicyParamsWithContext(ctx context.Context) *UpdateReplicationPolicyParams {
    45  	return &UpdateReplicationPolicyParams{
    46  		Context: ctx,
    47  	}
    48  }
    49  
    50  // NewUpdateReplicationPolicyParamsWithHTTPClient creates a new UpdateReplicationPolicyParams object
    51  // with the ability to set a custom HTTPClient for a request.
    52  func NewUpdateReplicationPolicyParamsWithHTTPClient(client *http.Client) *UpdateReplicationPolicyParams {
    53  	return &UpdateReplicationPolicyParams{
    54  		HTTPClient: client,
    55  	}
    56  }
    57  
    58  /*
    59  UpdateReplicationPolicyParams contains all the parameters to send to the API endpoint
    60  
    61  	for the update replication policy operation.
    62  
    63  	Typically these are written to a http.Request.
    64  */
    65  type UpdateReplicationPolicyParams struct {
    66  
    67  	/* XRequestID.
    68  
    69  	   An unique ID for the request
    70  	*/
    71  	XRequestID *string
    72  
    73  	/* ID.
    74  
    75  	   The policy ID
    76  
    77  	   Format: int64
    78  	*/
    79  	ID int64
    80  
    81  	/* Policy.
    82  
    83  	   The replication policy
    84  	*/
    85  	Policy *models.ReplicationPolicy
    86  
    87  	timeout    time.Duration
    88  	Context    context.Context
    89  	HTTPClient *http.Client
    90  }
    91  
    92  // WithDefaults hydrates default values in the update replication policy params (not the query body).
    93  //
    94  // All values with no default are reset to their zero value.
    95  func (o *UpdateReplicationPolicyParams) WithDefaults() *UpdateReplicationPolicyParams {
    96  	o.SetDefaults()
    97  	return o
    98  }
    99  
   100  // SetDefaults hydrates default values in the update replication policy params (not the query body).
   101  //
   102  // All values with no default are reset to their zero value.
   103  func (o *UpdateReplicationPolicyParams) SetDefaults() {
   104  	// no default values defined for this parameter
   105  }
   106  
   107  // WithTimeout adds the timeout to the update replication policy params
   108  func (o *UpdateReplicationPolicyParams) WithTimeout(timeout time.Duration) *UpdateReplicationPolicyParams {
   109  	o.SetTimeout(timeout)
   110  	return o
   111  }
   112  
   113  // SetTimeout adds the timeout to the update replication policy params
   114  func (o *UpdateReplicationPolicyParams) SetTimeout(timeout time.Duration) {
   115  	o.timeout = timeout
   116  }
   117  
   118  // WithContext adds the context to the update replication policy params
   119  func (o *UpdateReplicationPolicyParams) WithContext(ctx context.Context) *UpdateReplicationPolicyParams {
   120  	o.SetContext(ctx)
   121  	return o
   122  }
   123  
   124  // SetContext adds the context to the update replication policy params
   125  func (o *UpdateReplicationPolicyParams) SetContext(ctx context.Context) {
   126  	o.Context = ctx
   127  }
   128  
   129  // WithHTTPClient adds the HTTPClient to the update replication policy params
   130  func (o *UpdateReplicationPolicyParams) WithHTTPClient(client *http.Client) *UpdateReplicationPolicyParams {
   131  	o.SetHTTPClient(client)
   132  	return o
   133  }
   134  
   135  // SetHTTPClient adds the HTTPClient to the update replication policy params
   136  func (o *UpdateReplicationPolicyParams) SetHTTPClient(client *http.Client) {
   137  	o.HTTPClient = client
   138  }
   139  
   140  // WithXRequestID adds the xRequestID to the update replication policy params
   141  func (o *UpdateReplicationPolicyParams) WithXRequestID(xRequestID *string) *UpdateReplicationPolicyParams {
   142  	o.SetXRequestID(xRequestID)
   143  	return o
   144  }
   145  
   146  // SetXRequestID adds the xRequestId to the update replication policy params
   147  func (o *UpdateReplicationPolicyParams) SetXRequestID(xRequestID *string) {
   148  	o.XRequestID = xRequestID
   149  }
   150  
   151  // WithID adds the id to the update replication policy params
   152  func (o *UpdateReplicationPolicyParams) WithID(id int64) *UpdateReplicationPolicyParams {
   153  	o.SetID(id)
   154  	return o
   155  }
   156  
   157  // SetID adds the id to the update replication policy params
   158  func (o *UpdateReplicationPolicyParams) SetID(id int64) {
   159  	o.ID = id
   160  }
   161  
   162  // WithPolicy adds the policy to the update replication policy params
   163  func (o *UpdateReplicationPolicyParams) WithPolicy(policy *models.ReplicationPolicy) *UpdateReplicationPolicyParams {
   164  	o.SetPolicy(policy)
   165  	return o
   166  }
   167  
   168  // SetPolicy adds the policy to the update replication policy params
   169  func (o *UpdateReplicationPolicyParams) SetPolicy(policy *models.ReplicationPolicy) {
   170  	o.Policy = policy
   171  }
   172  
   173  // WriteToRequest writes these params to a swagger request
   174  func (o *UpdateReplicationPolicyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   175  
   176  	if err := r.SetTimeout(o.timeout); err != nil {
   177  		return err
   178  	}
   179  	var res []error
   180  
   181  	if o.XRequestID != nil {
   182  
   183  		// header param X-Request-Id
   184  		if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil {
   185  			return err
   186  		}
   187  	}
   188  
   189  	// path param id
   190  	if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
   191  		return err
   192  	}
   193  	if o.Policy != nil {
   194  		if err := r.SetBodyParam(o.Policy); err != nil {
   195  			return err
   196  		}
   197  	}
   198  
   199  	if len(res) > 0 {
   200  		return errors.CompositeValidationError(res...)
   201  	}
   202  	return nil
   203  }