github.com/cilium/cilium@v1.16.2/api/v1/client/policy/put_policy_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright Authors of Cilium
     4  // SPDX-License-Identifier: Apache-2.0
     5  
     6  package policy
     7  
     8  // This file was generated by the swagger tool.
     9  // Editing this file might prove futile when you re-run the swagger generate command
    10  
    11  import (
    12  	"fmt"
    13  	"io"
    14  
    15  	"github.com/go-openapi/runtime"
    16  	"github.com/go-openapi/strfmt"
    17  
    18  	"github.com/cilium/cilium/api/v1/models"
    19  )
    20  
    21  // PutPolicyReader is a Reader for the PutPolicy structure.
    22  type PutPolicyReader struct {
    23  	formats strfmt.Registry
    24  }
    25  
    26  // ReadResponse reads a server response into the received o.
    27  func (o *PutPolicyReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    28  	switch response.Code() {
    29  	case 200:
    30  		result := NewPutPolicyOK()
    31  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    32  			return nil, err
    33  		}
    34  		return result, nil
    35  	case 400:
    36  		result := NewPutPolicyInvalidPolicy()
    37  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    38  			return nil, err
    39  		}
    40  		return nil, result
    41  	case 403:
    42  		result := NewPutPolicyForbidden()
    43  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    44  			return nil, err
    45  		}
    46  		return nil, result
    47  	case 460:
    48  		result := NewPutPolicyInvalidPath()
    49  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    50  			return nil, err
    51  		}
    52  		return nil, result
    53  	case 500:
    54  		result := NewPutPolicyFailure()
    55  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    56  			return nil, err
    57  		}
    58  		return nil, result
    59  	default:
    60  		return nil, runtime.NewAPIError("[PUT /policy] PutPolicy", response, response.Code())
    61  	}
    62  }
    63  
    64  // NewPutPolicyOK creates a PutPolicyOK with default headers values
    65  func NewPutPolicyOK() *PutPolicyOK {
    66  	return &PutPolicyOK{}
    67  }
    68  
    69  /*
    70  PutPolicyOK describes a response with status code 200, with default header values.
    71  
    72  Success
    73  */
    74  type PutPolicyOK struct {
    75  	Payload *models.Policy
    76  }
    77  
    78  // IsSuccess returns true when this put policy o k response has a 2xx status code
    79  func (o *PutPolicyOK) IsSuccess() bool {
    80  	return true
    81  }
    82  
    83  // IsRedirect returns true when this put policy o k response has a 3xx status code
    84  func (o *PutPolicyOK) IsRedirect() bool {
    85  	return false
    86  }
    87  
    88  // IsClientError returns true when this put policy o k response has a 4xx status code
    89  func (o *PutPolicyOK) IsClientError() bool {
    90  	return false
    91  }
    92  
    93  // IsServerError returns true when this put policy o k response has a 5xx status code
    94  func (o *PutPolicyOK) IsServerError() bool {
    95  	return false
    96  }
    97  
    98  // IsCode returns true when this put policy o k response a status code equal to that given
    99  func (o *PutPolicyOK) IsCode(code int) bool {
   100  	return code == 200
   101  }
   102  
   103  // Code gets the status code for the put policy o k response
   104  func (o *PutPolicyOK) Code() int {
   105  	return 200
   106  }
   107  
   108  func (o *PutPolicyOK) Error() string {
   109  	return fmt.Sprintf("[PUT /policy][%d] putPolicyOK  %+v", 200, o.Payload)
   110  }
   111  
   112  func (o *PutPolicyOK) String() string {
   113  	return fmt.Sprintf("[PUT /policy][%d] putPolicyOK  %+v", 200, o.Payload)
   114  }
   115  
   116  func (o *PutPolicyOK) GetPayload() *models.Policy {
   117  	return o.Payload
   118  }
   119  
   120  func (o *PutPolicyOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   121  
   122  	o.Payload = new(models.Policy)
   123  
   124  	// response payload
   125  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   126  		return err
   127  	}
   128  
   129  	return nil
   130  }
   131  
   132  // NewPutPolicyInvalidPolicy creates a PutPolicyInvalidPolicy with default headers values
   133  func NewPutPolicyInvalidPolicy() *PutPolicyInvalidPolicy {
   134  	return &PutPolicyInvalidPolicy{}
   135  }
   136  
   137  /*
   138  PutPolicyInvalidPolicy describes a response with status code 400, with default header values.
   139  
   140  Invalid policy
   141  */
   142  type PutPolicyInvalidPolicy struct {
   143  	Payload models.Error
   144  }
   145  
   146  // IsSuccess returns true when this put policy invalid policy response has a 2xx status code
   147  func (o *PutPolicyInvalidPolicy) IsSuccess() bool {
   148  	return false
   149  }
   150  
   151  // IsRedirect returns true when this put policy invalid policy response has a 3xx status code
   152  func (o *PutPolicyInvalidPolicy) IsRedirect() bool {
   153  	return false
   154  }
   155  
   156  // IsClientError returns true when this put policy invalid policy response has a 4xx status code
   157  func (o *PutPolicyInvalidPolicy) IsClientError() bool {
   158  	return true
   159  }
   160  
   161  // IsServerError returns true when this put policy invalid policy response has a 5xx status code
   162  func (o *PutPolicyInvalidPolicy) IsServerError() bool {
   163  	return false
   164  }
   165  
   166  // IsCode returns true when this put policy invalid policy response a status code equal to that given
   167  func (o *PutPolicyInvalidPolicy) IsCode(code int) bool {
   168  	return code == 400
   169  }
   170  
   171  // Code gets the status code for the put policy invalid policy response
   172  func (o *PutPolicyInvalidPolicy) Code() int {
   173  	return 400
   174  }
   175  
   176  func (o *PutPolicyInvalidPolicy) Error() string {
   177  	return fmt.Sprintf("[PUT /policy][%d] putPolicyInvalidPolicy  %+v", 400, o.Payload)
   178  }
   179  
   180  func (o *PutPolicyInvalidPolicy) String() string {
   181  	return fmt.Sprintf("[PUT /policy][%d] putPolicyInvalidPolicy  %+v", 400, o.Payload)
   182  }
   183  
   184  func (o *PutPolicyInvalidPolicy) GetPayload() models.Error {
   185  	return o.Payload
   186  }
   187  
   188  func (o *PutPolicyInvalidPolicy) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   189  
   190  	// response payload
   191  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
   192  		return err
   193  	}
   194  
   195  	return nil
   196  }
   197  
   198  // NewPutPolicyForbidden creates a PutPolicyForbidden with default headers values
   199  func NewPutPolicyForbidden() *PutPolicyForbidden {
   200  	return &PutPolicyForbidden{}
   201  }
   202  
   203  /*
   204  PutPolicyForbidden describes a response with status code 403, with default header values.
   205  
   206  Forbidden
   207  */
   208  type PutPolicyForbidden struct {
   209  }
   210  
   211  // IsSuccess returns true when this put policy forbidden response has a 2xx status code
   212  func (o *PutPolicyForbidden) IsSuccess() bool {
   213  	return false
   214  }
   215  
   216  // IsRedirect returns true when this put policy forbidden response has a 3xx status code
   217  func (o *PutPolicyForbidden) IsRedirect() bool {
   218  	return false
   219  }
   220  
   221  // IsClientError returns true when this put policy forbidden response has a 4xx status code
   222  func (o *PutPolicyForbidden) IsClientError() bool {
   223  	return true
   224  }
   225  
   226  // IsServerError returns true when this put policy forbidden response has a 5xx status code
   227  func (o *PutPolicyForbidden) IsServerError() bool {
   228  	return false
   229  }
   230  
   231  // IsCode returns true when this put policy forbidden response a status code equal to that given
   232  func (o *PutPolicyForbidden) IsCode(code int) bool {
   233  	return code == 403
   234  }
   235  
   236  // Code gets the status code for the put policy forbidden response
   237  func (o *PutPolicyForbidden) Code() int {
   238  	return 403
   239  }
   240  
   241  func (o *PutPolicyForbidden) Error() string {
   242  	return fmt.Sprintf("[PUT /policy][%d] putPolicyForbidden ", 403)
   243  }
   244  
   245  func (o *PutPolicyForbidden) String() string {
   246  	return fmt.Sprintf("[PUT /policy][%d] putPolicyForbidden ", 403)
   247  }
   248  
   249  func (o *PutPolicyForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   250  
   251  	return nil
   252  }
   253  
   254  // NewPutPolicyInvalidPath creates a PutPolicyInvalidPath with default headers values
   255  func NewPutPolicyInvalidPath() *PutPolicyInvalidPath {
   256  	return &PutPolicyInvalidPath{}
   257  }
   258  
   259  /*
   260  PutPolicyInvalidPath describes a response with status code 460, with default header values.
   261  
   262  Invalid path
   263  */
   264  type PutPolicyInvalidPath struct {
   265  	Payload models.Error
   266  }
   267  
   268  // IsSuccess returns true when this put policy invalid path response has a 2xx status code
   269  func (o *PutPolicyInvalidPath) IsSuccess() bool {
   270  	return false
   271  }
   272  
   273  // IsRedirect returns true when this put policy invalid path response has a 3xx status code
   274  func (o *PutPolicyInvalidPath) IsRedirect() bool {
   275  	return false
   276  }
   277  
   278  // IsClientError returns true when this put policy invalid path response has a 4xx status code
   279  func (o *PutPolicyInvalidPath) IsClientError() bool {
   280  	return true
   281  }
   282  
   283  // IsServerError returns true when this put policy invalid path response has a 5xx status code
   284  func (o *PutPolicyInvalidPath) IsServerError() bool {
   285  	return false
   286  }
   287  
   288  // IsCode returns true when this put policy invalid path response a status code equal to that given
   289  func (o *PutPolicyInvalidPath) IsCode(code int) bool {
   290  	return code == 460
   291  }
   292  
   293  // Code gets the status code for the put policy invalid path response
   294  func (o *PutPolicyInvalidPath) Code() int {
   295  	return 460
   296  }
   297  
   298  func (o *PutPolicyInvalidPath) Error() string {
   299  	return fmt.Sprintf("[PUT /policy][%d] putPolicyInvalidPath  %+v", 460, o.Payload)
   300  }
   301  
   302  func (o *PutPolicyInvalidPath) String() string {
   303  	return fmt.Sprintf("[PUT /policy][%d] putPolicyInvalidPath  %+v", 460, o.Payload)
   304  }
   305  
   306  func (o *PutPolicyInvalidPath) GetPayload() models.Error {
   307  	return o.Payload
   308  }
   309  
   310  func (o *PutPolicyInvalidPath) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   311  
   312  	// response payload
   313  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
   314  		return err
   315  	}
   316  
   317  	return nil
   318  }
   319  
   320  // NewPutPolicyFailure creates a PutPolicyFailure with default headers values
   321  func NewPutPolicyFailure() *PutPolicyFailure {
   322  	return &PutPolicyFailure{}
   323  }
   324  
   325  /*
   326  PutPolicyFailure describes a response with status code 500, with default header values.
   327  
   328  Policy import failed
   329  */
   330  type PutPolicyFailure struct {
   331  	Payload models.Error
   332  }
   333  
   334  // IsSuccess returns true when this put policy failure response has a 2xx status code
   335  func (o *PutPolicyFailure) IsSuccess() bool {
   336  	return false
   337  }
   338  
   339  // IsRedirect returns true when this put policy failure response has a 3xx status code
   340  func (o *PutPolicyFailure) IsRedirect() bool {
   341  	return false
   342  }
   343  
   344  // IsClientError returns true when this put policy failure response has a 4xx status code
   345  func (o *PutPolicyFailure) IsClientError() bool {
   346  	return false
   347  }
   348  
   349  // IsServerError returns true when this put policy failure response has a 5xx status code
   350  func (o *PutPolicyFailure) IsServerError() bool {
   351  	return true
   352  }
   353  
   354  // IsCode returns true when this put policy failure response a status code equal to that given
   355  func (o *PutPolicyFailure) IsCode(code int) bool {
   356  	return code == 500
   357  }
   358  
   359  // Code gets the status code for the put policy failure response
   360  func (o *PutPolicyFailure) Code() int {
   361  	return 500
   362  }
   363  
   364  func (o *PutPolicyFailure) Error() string {
   365  	return fmt.Sprintf("[PUT /policy][%d] putPolicyFailure  %+v", 500, o.Payload)
   366  }
   367  
   368  func (o *PutPolicyFailure) String() string {
   369  	return fmt.Sprintf("[PUT /policy][%d] putPolicyFailure  %+v", 500, o.Payload)
   370  }
   371  
   372  func (o *PutPolicyFailure) GetPayload() models.Error {
   373  	return o.Payload
   374  }
   375  
   376  func (o *PutPolicyFailure) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   377  
   378  	// response payload
   379  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
   380  		return err
   381  	}
   382  
   383  	return nil
   384  }