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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package preheat
     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  // CreateInstanceReader is a Reader for the CreateInstance structure.
    19  type CreateInstanceReader struct {
    20  	formats strfmt.Registry
    21  }
    22  
    23  // ReadResponse reads a server response into the received o.
    24  func (o *CreateInstanceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    25  	switch response.Code() {
    26  	case 201:
    27  		result := NewCreateInstanceCreated()
    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 := NewCreateInstanceBadRequest()
    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 := NewCreateInstanceUnauthorized()
    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 := NewCreateInstanceForbidden()
    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 := NewCreateInstanceNotFound()
    52  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    53  			return nil, err
    54  		}
    55  		return nil, result
    56  	case 409:
    57  		result := NewCreateInstanceConflict()
    58  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    59  			return nil, err
    60  		}
    61  		return nil, result
    62  	case 500:
    63  		result := NewCreateInstanceInternalServerError()
    64  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    65  			return nil, err
    66  		}
    67  		return nil, result
    68  	default:
    69  		return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
    70  	}
    71  }
    72  
    73  // NewCreateInstanceCreated creates a CreateInstanceCreated with default headers values
    74  func NewCreateInstanceCreated() *CreateInstanceCreated {
    75  	return &CreateInstanceCreated{}
    76  }
    77  
    78  /*
    79  CreateInstanceCreated describes a response with status code 201, with default header values.
    80  
    81  Created
    82  */
    83  type CreateInstanceCreated struct {
    84  
    85  	/* The location of the resource
    86  	 */
    87  	Location string
    88  
    89  	/* The ID of the corresponding request for the response
    90  	 */
    91  	XRequestID string
    92  }
    93  
    94  // IsSuccess returns true when this create instance created response has a 2xx status code
    95  func (o *CreateInstanceCreated) IsSuccess() bool {
    96  	return true
    97  }
    98  
    99  // IsRedirect returns true when this create instance created response has a 3xx status code
   100  func (o *CreateInstanceCreated) IsRedirect() bool {
   101  	return false
   102  }
   103  
   104  // IsClientError returns true when this create instance created response has a 4xx status code
   105  func (o *CreateInstanceCreated) IsClientError() bool {
   106  	return false
   107  }
   108  
   109  // IsServerError returns true when this create instance created response has a 5xx status code
   110  func (o *CreateInstanceCreated) IsServerError() bool {
   111  	return false
   112  }
   113  
   114  // IsCode returns true when this create instance created response a status code equal to that given
   115  func (o *CreateInstanceCreated) IsCode(code int) bool {
   116  	return code == 201
   117  }
   118  
   119  func (o *CreateInstanceCreated) Error() string {
   120  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceCreated ", 201)
   121  }
   122  
   123  func (o *CreateInstanceCreated) String() string {
   124  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceCreated ", 201)
   125  }
   126  
   127  func (o *CreateInstanceCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   128  
   129  	// hydrates response header Location
   130  	hdrLocation := response.GetHeader("Location")
   131  
   132  	if hdrLocation != "" {
   133  		o.Location = hdrLocation
   134  	}
   135  
   136  	// hydrates response header X-Request-Id
   137  	hdrXRequestID := response.GetHeader("X-Request-Id")
   138  
   139  	if hdrXRequestID != "" {
   140  		o.XRequestID = hdrXRequestID
   141  	}
   142  
   143  	return nil
   144  }
   145  
   146  // NewCreateInstanceBadRequest creates a CreateInstanceBadRequest with default headers values
   147  func NewCreateInstanceBadRequest() *CreateInstanceBadRequest {
   148  	return &CreateInstanceBadRequest{}
   149  }
   150  
   151  /*
   152  CreateInstanceBadRequest describes a response with status code 400, with default header values.
   153  
   154  Bad request
   155  */
   156  type CreateInstanceBadRequest struct {
   157  
   158  	/* The ID of the corresponding request for the response
   159  	 */
   160  	XRequestID string
   161  
   162  	Payload *models.Errors
   163  }
   164  
   165  // IsSuccess returns true when this create instance bad request response has a 2xx status code
   166  func (o *CreateInstanceBadRequest) IsSuccess() bool {
   167  	return false
   168  }
   169  
   170  // IsRedirect returns true when this create instance bad request response has a 3xx status code
   171  func (o *CreateInstanceBadRequest) IsRedirect() bool {
   172  	return false
   173  }
   174  
   175  // IsClientError returns true when this create instance bad request response has a 4xx status code
   176  func (o *CreateInstanceBadRequest) IsClientError() bool {
   177  	return true
   178  }
   179  
   180  // IsServerError returns true when this create instance bad request response has a 5xx status code
   181  func (o *CreateInstanceBadRequest) IsServerError() bool {
   182  	return false
   183  }
   184  
   185  // IsCode returns true when this create instance bad request response a status code equal to that given
   186  func (o *CreateInstanceBadRequest) IsCode(code int) bool {
   187  	return code == 400
   188  }
   189  
   190  func (o *CreateInstanceBadRequest) Error() string {
   191  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceBadRequest  %+v", 400, o.Payload)
   192  }
   193  
   194  func (o *CreateInstanceBadRequest) String() string {
   195  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceBadRequest  %+v", 400, o.Payload)
   196  }
   197  
   198  func (o *CreateInstanceBadRequest) GetPayload() *models.Errors {
   199  	return o.Payload
   200  }
   201  
   202  func (o *CreateInstanceBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   203  
   204  	// hydrates response header X-Request-Id
   205  	hdrXRequestID := response.GetHeader("X-Request-Id")
   206  
   207  	if hdrXRequestID != "" {
   208  		o.XRequestID = hdrXRequestID
   209  	}
   210  
   211  	o.Payload = new(models.Errors)
   212  
   213  	// response payload
   214  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   215  		return err
   216  	}
   217  
   218  	return nil
   219  }
   220  
   221  // NewCreateInstanceUnauthorized creates a CreateInstanceUnauthorized with default headers values
   222  func NewCreateInstanceUnauthorized() *CreateInstanceUnauthorized {
   223  	return &CreateInstanceUnauthorized{}
   224  }
   225  
   226  /*
   227  CreateInstanceUnauthorized describes a response with status code 401, with default header values.
   228  
   229  Unauthorized
   230  */
   231  type CreateInstanceUnauthorized struct {
   232  
   233  	/* The ID of the corresponding request for the response
   234  	 */
   235  	XRequestID string
   236  
   237  	Payload *models.Errors
   238  }
   239  
   240  // IsSuccess returns true when this create instance unauthorized response has a 2xx status code
   241  func (o *CreateInstanceUnauthorized) IsSuccess() bool {
   242  	return false
   243  }
   244  
   245  // IsRedirect returns true when this create instance unauthorized response has a 3xx status code
   246  func (o *CreateInstanceUnauthorized) IsRedirect() bool {
   247  	return false
   248  }
   249  
   250  // IsClientError returns true when this create instance unauthorized response has a 4xx status code
   251  func (o *CreateInstanceUnauthorized) IsClientError() bool {
   252  	return true
   253  }
   254  
   255  // IsServerError returns true when this create instance unauthorized response has a 5xx status code
   256  func (o *CreateInstanceUnauthorized) IsServerError() bool {
   257  	return false
   258  }
   259  
   260  // IsCode returns true when this create instance unauthorized response a status code equal to that given
   261  func (o *CreateInstanceUnauthorized) IsCode(code int) bool {
   262  	return code == 401
   263  }
   264  
   265  func (o *CreateInstanceUnauthorized) Error() string {
   266  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceUnauthorized  %+v", 401, o.Payload)
   267  }
   268  
   269  func (o *CreateInstanceUnauthorized) String() string {
   270  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceUnauthorized  %+v", 401, o.Payload)
   271  }
   272  
   273  func (o *CreateInstanceUnauthorized) GetPayload() *models.Errors {
   274  	return o.Payload
   275  }
   276  
   277  func (o *CreateInstanceUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   278  
   279  	// hydrates response header X-Request-Id
   280  	hdrXRequestID := response.GetHeader("X-Request-Id")
   281  
   282  	if hdrXRequestID != "" {
   283  		o.XRequestID = hdrXRequestID
   284  	}
   285  
   286  	o.Payload = new(models.Errors)
   287  
   288  	// response payload
   289  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   290  		return err
   291  	}
   292  
   293  	return nil
   294  }
   295  
   296  // NewCreateInstanceForbidden creates a CreateInstanceForbidden with default headers values
   297  func NewCreateInstanceForbidden() *CreateInstanceForbidden {
   298  	return &CreateInstanceForbidden{}
   299  }
   300  
   301  /*
   302  CreateInstanceForbidden describes a response with status code 403, with default header values.
   303  
   304  Forbidden
   305  */
   306  type CreateInstanceForbidden struct {
   307  
   308  	/* The ID of the corresponding request for the response
   309  	 */
   310  	XRequestID string
   311  
   312  	Payload *models.Errors
   313  }
   314  
   315  // IsSuccess returns true when this create instance forbidden response has a 2xx status code
   316  func (o *CreateInstanceForbidden) IsSuccess() bool {
   317  	return false
   318  }
   319  
   320  // IsRedirect returns true when this create instance forbidden response has a 3xx status code
   321  func (o *CreateInstanceForbidden) IsRedirect() bool {
   322  	return false
   323  }
   324  
   325  // IsClientError returns true when this create instance forbidden response has a 4xx status code
   326  func (o *CreateInstanceForbidden) IsClientError() bool {
   327  	return true
   328  }
   329  
   330  // IsServerError returns true when this create instance forbidden response has a 5xx status code
   331  func (o *CreateInstanceForbidden) IsServerError() bool {
   332  	return false
   333  }
   334  
   335  // IsCode returns true when this create instance forbidden response a status code equal to that given
   336  func (o *CreateInstanceForbidden) IsCode(code int) bool {
   337  	return code == 403
   338  }
   339  
   340  func (o *CreateInstanceForbidden) Error() string {
   341  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceForbidden  %+v", 403, o.Payload)
   342  }
   343  
   344  func (o *CreateInstanceForbidden) String() string {
   345  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceForbidden  %+v", 403, o.Payload)
   346  }
   347  
   348  func (o *CreateInstanceForbidden) GetPayload() *models.Errors {
   349  	return o.Payload
   350  }
   351  
   352  func (o *CreateInstanceForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   353  
   354  	// hydrates response header X-Request-Id
   355  	hdrXRequestID := response.GetHeader("X-Request-Id")
   356  
   357  	if hdrXRequestID != "" {
   358  		o.XRequestID = hdrXRequestID
   359  	}
   360  
   361  	o.Payload = new(models.Errors)
   362  
   363  	// response payload
   364  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   365  		return err
   366  	}
   367  
   368  	return nil
   369  }
   370  
   371  // NewCreateInstanceNotFound creates a CreateInstanceNotFound with default headers values
   372  func NewCreateInstanceNotFound() *CreateInstanceNotFound {
   373  	return &CreateInstanceNotFound{}
   374  }
   375  
   376  /*
   377  CreateInstanceNotFound describes a response with status code 404, with default header values.
   378  
   379  Not found
   380  */
   381  type CreateInstanceNotFound struct {
   382  
   383  	/* The ID of the corresponding request for the response
   384  	 */
   385  	XRequestID string
   386  
   387  	Payload *models.Errors
   388  }
   389  
   390  // IsSuccess returns true when this create instance not found response has a 2xx status code
   391  func (o *CreateInstanceNotFound) IsSuccess() bool {
   392  	return false
   393  }
   394  
   395  // IsRedirect returns true when this create instance not found response has a 3xx status code
   396  func (o *CreateInstanceNotFound) IsRedirect() bool {
   397  	return false
   398  }
   399  
   400  // IsClientError returns true when this create instance not found response has a 4xx status code
   401  func (o *CreateInstanceNotFound) IsClientError() bool {
   402  	return true
   403  }
   404  
   405  // IsServerError returns true when this create instance not found response has a 5xx status code
   406  func (o *CreateInstanceNotFound) IsServerError() bool {
   407  	return false
   408  }
   409  
   410  // IsCode returns true when this create instance not found response a status code equal to that given
   411  func (o *CreateInstanceNotFound) IsCode(code int) bool {
   412  	return code == 404
   413  }
   414  
   415  func (o *CreateInstanceNotFound) Error() string {
   416  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceNotFound  %+v", 404, o.Payload)
   417  }
   418  
   419  func (o *CreateInstanceNotFound) String() string {
   420  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceNotFound  %+v", 404, o.Payload)
   421  }
   422  
   423  func (o *CreateInstanceNotFound) GetPayload() *models.Errors {
   424  	return o.Payload
   425  }
   426  
   427  func (o *CreateInstanceNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   428  
   429  	// hydrates response header X-Request-Id
   430  	hdrXRequestID := response.GetHeader("X-Request-Id")
   431  
   432  	if hdrXRequestID != "" {
   433  		o.XRequestID = hdrXRequestID
   434  	}
   435  
   436  	o.Payload = new(models.Errors)
   437  
   438  	// response payload
   439  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   440  		return err
   441  	}
   442  
   443  	return nil
   444  }
   445  
   446  // NewCreateInstanceConflict creates a CreateInstanceConflict with default headers values
   447  func NewCreateInstanceConflict() *CreateInstanceConflict {
   448  	return &CreateInstanceConflict{}
   449  }
   450  
   451  /*
   452  CreateInstanceConflict describes a response with status code 409, with default header values.
   453  
   454  Conflict
   455  */
   456  type CreateInstanceConflict struct {
   457  
   458  	/* The ID of the corresponding request for the response
   459  	 */
   460  	XRequestID string
   461  
   462  	Payload *models.Errors
   463  }
   464  
   465  // IsSuccess returns true when this create instance conflict response has a 2xx status code
   466  func (o *CreateInstanceConflict) IsSuccess() bool {
   467  	return false
   468  }
   469  
   470  // IsRedirect returns true when this create instance conflict response has a 3xx status code
   471  func (o *CreateInstanceConflict) IsRedirect() bool {
   472  	return false
   473  }
   474  
   475  // IsClientError returns true when this create instance conflict response has a 4xx status code
   476  func (o *CreateInstanceConflict) IsClientError() bool {
   477  	return true
   478  }
   479  
   480  // IsServerError returns true when this create instance conflict response has a 5xx status code
   481  func (o *CreateInstanceConflict) IsServerError() bool {
   482  	return false
   483  }
   484  
   485  // IsCode returns true when this create instance conflict response a status code equal to that given
   486  func (o *CreateInstanceConflict) IsCode(code int) bool {
   487  	return code == 409
   488  }
   489  
   490  func (o *CreateInstanceConflict) Error() string {
   491  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceConflict  %+v", 409, o.Payload)
   492  }
   493  
   494  func (o *CreateInstanceConflict) String() string {
   495  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceConflict  %+v", 409, o.Payload)
   496  }
   497  
   498  func (o *CreateInstanceConflict) GetPayload() *models.Errors {
   499  	return o.Payload
   500  }
   501  
   502  func (o *CreateInstanceConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   503  
   504  	// hydrates response header X-Request-Id
   505  	hdrXRequestID := response.GetHeader("X-Request-Id")
   506  
   507  	if hdrXRequestID != "" {
   508  		o.XRequestID = hdrXRequestID
   509  	}
   510  
   511  	o.Payload = new(models.Errors)
   512  
   513  	// response payload
   514  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   515  		return err
   516  	}
   517  
   518  	return nil
   519  }
   520  
   521  // NewCreateInstanceInternalServerError creates a CreateInstanceInternalServerError with default headers values
   522  func NewCreateInstanceInternalServerError() *CreateInstanceInternalServerError {
   523  	return &CreateInstanceInternalServerError{}
   524  }
   525  
   526  /*
   527  CreateInstanceInternalServerError describes a response with status code 500, with default header values.
   528  
   529  Internal server error
   530  */
   531  type CreateInstanceInternalServerError struct {
   532  
   533  	/* The ID of the corresponding request for the response
   534  	 */
   535  	XRequestID string
   536  
   537  	Payload *models.Errors
   538  }
   539  
   540  // IsSuccess returns true when this create instance internal server error response has a 2xx status code
   541  func (o *CreateInstanceInternalServerError) IsSuccess() bool {
   542  	return false
   543  }
   544  
   545  // IsRedirect returns true when this create instance internal server error response has a 3xx status code
   546  func (o *CreateInstanceInternalServerError) IsRedirect() bool {
   547  	return false
   548  }
   549  
   550  // IsClientError returns true when this create instance internal server error response has a 4xx status code
   551  func (o *CreateInstanceInternalServerError) IsClientError() bool {
   552  	return false
   553  }
   554  
   555  // IsServerError returns true when this create instance internal server error response has a 5xx status code
   556  func (o *CreateInstanceInternalServerError) IsServerError() bool {
   557  	return true
   558  }
   559  
   560  // IsCode returns true when this create instance internal server error response a status code equal to that given
   561  func (o *CreateInstanceInternalServerError) IsCode(code int) bool {
   562  	return code == 500
   563  }
   564  
   565  func (o *CreateInstanceInternalServerError) Error() string {
   566  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceInternalServerError  %+v", 500, o.Payload)
   567  }
   568  
   569  func (o *CreateInstanceInternalServerError) String() string {
   570  	return fmt.Sprintf("[POST /p2p/preheat/instances][%d] createInstanceInternalServerError  %+v", 500, o.Payload)
   571  }
   572  
   573  func (o *CreateInstanceInternalServerError) GetPayload() *models.Errors {
   574  	return o.Payload
   575  }
   576  
   577  func (o *CreateInstanceInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   578  
   579  	// hydrates response header X-Request-Id
   580  	hdrXRequestID := response.GetHeader("X-Request-Id")
   581  
   582  	if hdrXRequestID != "" {
   583  		o.XRequestID = hdrXRequestID
   584  	}
   585  
   586  	o.Payload = new(models.Errors)
   587  
   588  	// response payload
   589  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   590  		return err
   591  	}
   592  
   593  	return nil
   594  }