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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package immutable
     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  	"io"
    11  
    12  	"github.com/go-openapi/runtime"
    13  	"github.com/go-openapi/strfmt"
    14  
    15  	"github.com/goharbor/go-client/pkg/sdk/v2.0/models"
    16  )
    17  
    18  // CreateImmuRuleReader is a Reader for the CreateImmuRule structure.
    19  type CreateImmuRuleReader struct {
    20  	formats strfmt.Registry
    21  }
    22  
    23  // ReadResponse reads a server response into the received o.
    24  func (o *CreateImmuRuleReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    25  	switch response.Code() {
    26  	case 201:
    27  		result := NewCreateImmuRuleCreated()
    28  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    29  			return nil, err
    30  		}
    31  		return result, nil
    32  	case 400:
    33  		result := NewCreateImmuRuleBadRequest()
    34  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    35  			return nil, err
    36  		}
    37  		return nil, result
    38  	case 401:
    39  		result := NewCreateImmuRuleUnauthorized()
    40  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    41  			return nil, err
    42  		}
    43  		return nil, result
    44  	case 403:
    45  		result := NewCreateImmuRuleForbidden()
    46  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    47  			return nil, err
    48  		}
    49  		return nil, result
    50  	case 404:
    51  		result := NewCreateImmuRuleNotFound()
    52  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    53  			return nil, err
    54  		}
    55  		return nil, result
    56  	case 500:
    57  		result := NewCreateImmuRuleInternalServerError()
    58  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    59  			return nil, err
    60  		}
    61  		return nil, result
    62  	default:
    63  		return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
    64  	}
    65  }
    66  
    67  // NewCreateImmuRuleCreated creates a CreateImmuRuleCreated with default headers values
    68  func NewCreateImmuRuleCreated() *CreateImmuRuleCreated {
    69  	return &CreateImmuRuleCreated{}
    70  }
    71  
    72  /*
    73  CreateImmuRuleCreated describes a response with status code 201, with default header values.
    74  
    75  Created
    76  */
    77  type CreateImmuRuleCreated struct {
    78  
    79  	/* The location of the resource
    80  	 */
    81  	Location string
    82  
    83  	/* The ID of the corresponding request for the response
    84  	 */
    85  	XRequestID string
    86  }
    87  
    88  // IsSuccess returns true when this create immu rule created response has a 2xx status code
    89  func (o *CreateImmuRuleCreated) IsSuccess() bool {
    90  	return true
    91  }
    92  
    93  // IsRedirect returns true when this create immu rule created response has a 3xx status code
    94  func (o *CreateImmuRuleCreated) IsRedirect() bool {
    95  	return false
    96  }
    97  
    98  // IsClientError returns true when this create immu rule created response has a 4xx status code
    99  func (o *CreateImmuRuleCreated) IsClientError() bool {
   100  	return false
   101  }
   102  
   103  // IsServerError returns true when this create immu rule created response has a 5xx status code
   104  func (o *CreateImmuRuleCreated) IsServerError() bool {
   105  	return false
   106  }
   107  
   108  // IsCode returns true when this create immu rule created response a status code equal to that given
   109  func (o *CreateImmuRuleCreated) IsCode(code int) bool {
   110  	return code == 201
   111  }
   112  
   113  func (o *CreateImmuRuleCreated) Error() string {
   114  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleCreated ", 201)
   115  }
   116  
   117  func (o *CreateImmuRuleCreated) String() string {
   118  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleCreated ", 201)
   119  }
   120  
   121  func (o *CreateImmuRuleCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   122  
   123  	// hydrates response header Location
   124  	hdrLocation := response.GetHeader("Location")
   125  
   126  	if hdrLocation != "" {
   127  		o.Location = hdrLocation
   128  	}
   129  
   130  	// hydrates response header X-Request-Id
   131  	hdrXRequestID := response.GetHeader("X-Request-Id")
   132  
   133  	if hdrXRequestID != "" {
   134  		o.XRequestID = hdrXRequestID
   135  	}
   136  
   137  	return nil
   138  }
   139  
   140  // NewCreateImmuRuleBadRequest creates a CreateImmuRuleBadRequest with default headers values
   141  func NewCreateImmuRuleBadRequest() *CreateImmuRuleBadRequest {
   142  	return &CreateImmuRuleBadRequest{}
   143  }
   144  
   145  /*
   146  CreateImmuRuleBadRequest describes a response with status code 400, with default header values.
   147  
   148  Bad request
   149  */
   150  type CreateImmuRuleBadRequest struct {
   151  
   152  	/* The ID of the corresponding request for the response
   153  	 */
   154  	XRequestID string
   155  
   156  	Payload *models.Errors
   157  }
   158  
   159  // IsSuccess returns true when this create immu rule bad request response has a 2xx status code
   160  func (o *CreateImmuRuleBadRequest) IsSuccess() bool {
   161  	return false
   162  }
   163  
   164  // IsRedirect returns true when this create immu rule bad request response has a 3xx status code
   165  func (o *CreateImmuRuleBadRequest) IsRedirect() bool {
   166  	return false
   167  }
   168  
   169  // IsClientError returns true when this create immu rule bad request response has a 4xx status code
   170  func (o *CreateImmuRuleBadRequest) IsClientError() bool {
   171  	return true
   172  }
   173  
   174  // IsServerError returns true when this create immu rule bad request response has a 5xx status code
   175  func (o *CreateImmuRuleBadRequest) IsServerError() bool {
   176  	return false
   177  }
   178  
   179  // IsCode returns true when this create immu rule bad request response a status code equal to that given
   180  func (o *CreateImmuRuleBadRequest) IsCode(code int) bool {
   181  	return code == 400
   182  }
   183  
   184  func (o *CreateImmuRuleBadRequest) Error() string {
   185  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleBadRequest  %+v", 400, o.Payload)
   186  }
   187  
   188  func (o *CreateImmuRuleBadRequest) String() string {
   189  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleBadRequest  %+v", 400, o.Payload)
   190  }
   191  
   192  func (o *CreateImmuRuleBadRequest) GetPayload() *models.Errors {
   193  	return o.Payload
   194  }
   195  
   196  func (o *CreateImmuRuleBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   197  
   198  	// hydrates response header X-Request-Id
   199  	hdrXRequestID := response.GetHeader("X-Request-Id")
   200  
   201  	if hdrXRequestID != "" {
   202  		o.XRequestID = hdrXRequestID
   203  	}
   204  
   205  	o.Payload = new(models.Errors)
   206  
   207  	// response payload
   208  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   209  		return err
   210  	}
   211  
   212  	return nil
   213  }
   214  
   215  // NewCreateImmuRuleUnauthorized creates a CreateImmuRuleUnauthorized with default headers values
   216  func NewCreateImmuRuleUnauthorized() *CreateImmuRuleUnauthorized {
   217  	return &CreateImmuRuleUnauthorized{}
   218  }
   219  
   220  /*
   221  CreateImmuRuleUnauthorized describes a response with status code 401, with default header values.
   222  
   223  Unauthorized
   224  */
   225  type CreateImmuRuleUnauthorized struct {
   226  
   227  	/* The ID of the corresponding request for the response
   228  	 */
   229  	XRequestID string
   230  
   231  	Payload *models.Errors
   232  }
   233  
   234  // IsSuccess returns true when this create immu rule unauthorized response has a 2xx status code
   235  func (o *CreateImmuRuleUnauthorized) IsSuccess() bool {
   236  	return false
   237  }
   238  
   239  // IsRedirect returns true when this create immu rule unauthorized response has a 3xx status code
   240  func (o *CreateImmuRuleUnauthorized) IsRedirect() bool {
   241  	return false
   242  }
   243  
   244  // IsClientError returns true when this create immu rule unauthorized response has a 4xx status code
   245  func (o *CreateImmuRuleUnauthorized) IsClientError() bool {
   246  	return true
   247  }
   248  
   249  // IsServerError returns true when this create immu rule unauthorized response has a 5xx status code
   250  func (o *CreateImmuRuleUnauthorized) IsServerError() bool {
   251  	return false
   252  }
   253  
   254  // IsCode returns true when this create immu rule unauthorized response a status code equal to that given
   255  func (o *CreateImmuRuleUnauthorized) IsCode(code int) bool {
   256  	return code == 401
   257  }
   258  
   259  func (o *CreateImmuRuleUnauthorized) Error() string {
   260  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleUnauthorized  %+v", 401, o.Payload)
   261  }
   262  
   263  func (o *CreateImmuRuleUnauthorized) String() string {
   264  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleUnauthorized  %+v", 401, o.Payload)
   265  }
   266  
   267  func (o *CreateImmuRuleUnauthorized) GetPayload() *models.Errors {
   268  	return o.Payload
   269  }
   270  
   271  func (o *CreateImmuRuleUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   272  
   273  	// hydrates response header X-Request-Id
   274  	hdrXRequestID := response.GetHeader("X-Request-Id")
   275  
   276  	if hdrXRequestID != "" {
   277  		o.XRequestID = hdrXRequestID
   278  	}
   279  
   280  	o.Payload = new(models.Errors)
   281  
   282  	// response payload
   283  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   284  		return err
   285  	}
   286  
   287  	return nil
   288  }
   289  
   290  // NewCreateImmuRuleForbidden creates a CreateImmuRuleForbidden with default headers values
   291  func NewCreateImmuRuleForbidden() *CreateImmuRuleForbidden {
   292  	return &CreateImmuRuleForbidden{}
   293  }
   294  
   295  /*
   296  CreateImmuRuleForbidden describes a response with status code 403, with default header values.
   297  
   298  Forbidden
   299  */
   300  type CreateImmuRuleForbidden struct {
   301  
   302  	/* The ID of the corresponding request for the response
   303  	 */
   304  	XRequestID string
   305  
   306  	Payload *models.Errors
   307  }
   308  
   309  // IsSuccess returns true when this create immu rule forbidden response has a 2xx status code
   310  func (o *CreateImmuRuleForbidden) IsSuccess() bool {
   311  	return false
   312  }
   313  
   314  // IsRedirect returns true when this create immu rule forbidden response has a 3xx status code
   315  func (o *CreateImmuRuleForbidden) IsRedirect() bool {
   316  	return false
   317  }
   318  
   319  // IsClientError returns true when this create immu rule forbidden response has a 4xx status code
   320  func (o *CreateImmuRuleForbidden) IsClientError() bool {
   321  	return true
   322  }
   323  
   324  // IsServerError returns true when this create immu rule forbidden response has a 5xx status code
   325  func (o *CreateImmuRuleForbidden) IsServerError() bool {
   326  	return false
   327  }
   328  
   329  // IsCode returns true when this create immu rule forbidden response a status code equal to that given
   330  func (o *CreateImmuRuleForbidden) IsCode(code int) bool {
   331  	return code == 403
   332  }
   333  
   334  func (o *CreateImmuRuleForbidden) Error() string {
   335  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleForbidden  %+v", 403, o.Payload)
   336  }
   337  
   338  func (o *CreateImmuRuleForbidden) String() string {
   339  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleForbidden  %+v", 403, o.Payload)
   340  }
   341  
   342  func (o *CreateImmuRuleForbidden) GetPayload() *models.Errors {
   343  	return o.Payload
   344  }
   345  
   346  func (o *CreateImmuRuleForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   347  
   348  	// hydrates response header X-Request-Id
   349  	hdrXRequestID := response.GetHeader("X-Request-Id")
   350  
   351  	if hdrXRequestID != "" {
   352  		o.XRequestID = hdrXRequestID
   353  	}
   354  
   355  	o.Payload = new(models.Errors)
   356  
   357  	// response payload
   358  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   359  		return err
   360  	}
   361  
   362  	return nil
   363  }
   364  
   365  // NewCreateImmuRuleNotFound creates a CreateImmuRuleNotFound with default headers values
   366  func NewCreateImmuRuleNotFound() *CreateImmuRuleNotFound {
   367  	return &CreateImmuRuleNotFound{}
   368  }
   369  
   370  /*
   371  CreateImmuRuleNotFound describes a response with status code 404, with default header values.
   372  
   373  Not found
   374  */
   375  type CreateImmuRuleNotFound struct {
   376  
   377  	/* The ID of the corresponding request for the response
   378  	 */
   379  	XRequestID string
   380  
   381  	Payload *models.Errors
   382  }
   383  
   384  // IsSuccess returns true when this create immu rule not found response has a 2xx status code
   385  func (o *CreateImmuRuleNotFound) IsSuccess() bool {
   386  	return false
   387  }
   388  
   389  // IsRedirect returns true when this create immu rule not found response has a 3xx status code
   390  func (o *CreateImmuRuleNotFound) IsRedirect() bool {
   391  	return false
   392  }
   393  
   394  // IsClientError returns true when this create immu rule not found response has a 4xx status code
   395  func (o *CreateImmuRuleNotFound) IsClientError() bool {
   396  	return true
   397  }
   398  
   399  // IsServerError returns true when this create immu rule not found response has a 5xx status code
   400  func (o *CreateImmuRuleNotFound) IsServerError() bool {
   401  	return false
   402  }
   403  
   404  // IsCode returns true when this create immu rule not found response a status code equal to that given
   405  func (o *CreateImmuRuleNotFound) IsCode(code int) bool {
   406  	return code == 404
   407  }
   408  
   409  func (o *CreateImmuRuleNotFound) Error() string {
   410  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleNotFound  %+v", 404, o.Payload)
   411  }
   412  
   413  func (o *CreateImmuRuleNotFound) String() string {
   414  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleNotFound  %+v", 404, o.Payload)
   415  }
   416  
   417  func (o *CreateImmuRuleNotFound) GetPayload() *models.Errors {
   418  	return o.Payload
   419  }
   420  
   421  func (o *CreateImmuRuleNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   422  
   423  	// hydrates response header X-Request-Id
   424  	hdrXRequestID := response.GetHeader("X-Request-Id")
   425  
   426  	if hdrXRequestID != "" {
   427  		o.XRequestID = hdrXRequestID
   428  	}
   429  
   430  	o.Payload = new(models.Errors)
   431  
   432  	// response payload
   433  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   434  		return err
   435  	}
   436  
   437  	return nil
   438  }
   439  
   440  // NewCreateImmuRuleInternalServerError creates a CreateImmuRuleInternalServerError with default headers values
   441  func NewCreateImmuRuleInternalServerError() *CreateImmuRuleInternalServerError {
   442  	return &CreateImmuRuleInternalServerError{}
   443  }
   444  
   445  /*
   446  CreateImmuRuleInternalServerError describes a response with status code 500, with default header values.
   447  
   448  Internal server error
   449  */
   450  type CreateImmuRuleInternalServerError struct {
   451  
   452  	/* The ID of the corresponding request for the response
   453  	 */
   454  	XRequestID string
   455  
   456  	Payload *models.Errors
   457  }
   458  
   459  // IsSuccess returns true when this create immu rule internal server error response has a 2xx status code
   460  func (o *CreateImmuRuleInternalServerError) IsSuccess() bool {
   461  	return false
   462  }
   463  
   464  // IsRedirect returns true when this create immu rule internal server error response has a 3xx status code
   465  func (o *CreateImmuRuleInternalServerError) IsRedirect() bool {
   466  	return false
   467  }
   468  
   469  // IsClientError returns true when this create immu rule internal server error response has a 4xx status code
   470  func (o *CreateImmuRuleInternalServerError) IsClientError() bool {
   471  	return false
   472  }
   473  
   474  // IsServerError returns true when this create immu rule internal server error response has a 5xx status code
   475  func (o *CreateImmuRuleInternalServerError) IsServerError() bool {
   476  	return true
   477  }
   478  
   479  // IsCode returns true when this create immu rule internal server error response a status code equal to that given
   480  func (o *CreateImmuRuleInternalServerError) IsCode(code int) bool {
   481  	return code == 500
   482  }
   483  
   484  func (o *CreateImmuRuleInternalServerError) Error() string {
   485  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleInternalServerError  %+v", 500, o.Payload)
   486  }
   487  
   488  func (o *CreateImmuRuleInternalServerError) String() string {
   489  	return fmt.Sprintf("[POST /projects/{project_name_or_id}/immutabletagrules][%d] createImmuRuleInternalServerError  %+v", 500, o.Payload)
   490  }
   491  
   492  func (o *CreateImmuRuleInternalServerError) GetPayload() *models.Errors {
   493  	return o.Payload
   494  }
   495  
   496  func (o *CreateImmuRuleInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   497  
   498  	// hydrates response header X-Request-Id
   499  	hdrXRequestID := response.GetHeader("X-Request-Id")
   500  
   501  	if hdrXRequestID != "" {
   502  		o.XRequestID = hdrXRequestID
   503  	}
   504  
   505  	o.Payload = new(models.Errors)
   506  
   507  	// response payload
   508  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   509  		return err
   510  	}
   511  
   512  	return nil
   513  }