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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package robot
     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/errors"
    13  	"github.com/go-openapi/runtime"
    14  	"github.com/go-openapi/strfmt"
    15  	"github.com/go-openapi/swag"
    16  
    17  	"github.com/goharbor/go-client/pkg/sdk/v2.0/models"
    18  )
    19  
    20  // ListRobotReader is a Reader for the ListRobot structure.
    21  type ListRobotReader struct {
    22  	formats strfmt.Registry
    23  }
    24  
    25  // ReadResponse reads a server response into the received o.
    26  func (o *ListRobotReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    27  	switch response.Code() {
    28  	case 200:
    29  		result := NewListRobotOK()
    30  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    31  			return nil, err
    32  		}
    33  		return result, nil
    34  	case 400:
    35  		result := NewListRobotBadRequest()
    36  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    37  			return nil, err
    38  		}
    39  		return nil, result
    40  	case 404:
    41  		result := NewListRobotNotFound()
    42  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    43  			return nil, err
    44  		}
    45  		return nil, result
    46  	case 500:
    47  		result := NewListRobotInternalServerError()
    48  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    49  			return nil, err
    50  		}
    51  		return nil, result
    52  	default:
    53  		return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
    54  	}
    55  }
    56  
    57  // NewListRobotOK creates a ListRobotOK with default headers values
    58  func NewListRobotOK() *ListRobotOK {
    59  	return &ListRobotOK{}
    60  }
    61  
    62  /*
    63  ListRobotOK describes a response with status code 200, with default header values.
    64  
    65  Success
    66  */
    67  type ListRobotOK struct {
    68  
    69  	/* Link refers to the previous page and next page
    70  	 */
    71  	Link string
    72  
    73  	/* The total count of robot accounts
    74  	 */
    75  	XTotalCount int64
    76  
    77  	Payload []*models.Robot
    78  }
    79  
    80  // IsSuccess returns true when this list robot o k response has a 2xx status code
    81  func (o *ListRobotOK) IsSuccess() bool {
    82  	return true
    83  }
    84  
    85  // IsRedirect returns true when this list robot o k response has a 3xx status code
    86  func (o *ListRobotOK) IsRedirect() bool {
    87  	return false
    88  }
    89  
    90  // IsClientError returns true when this list robot o k response has a 4xx status code
    91  func (o *ListRobotOK) IsClientError() bool {
    92  	return false
    93  }
    94  
    95  // IsServerError returns true when this list robot o k response has a 5xx status code
    96  func (o *ListRobotOK) IsServerError() bool {
    97  	return false
    98  }
    99  
   100  // IsCode returns true when this list robot o k response a status code equal to that given
   101  func (o *ListRobotOK) IsCode(code int) bool {
   102  	return code == 200
   103  }
   104  
   105  func (o *ListRobotOK) Error() string {
   106  	return fmt.Sprintf("[GET /robots][%d] listRobotOK  %+v", 200, o.Payload)
   107  }
   108  
   109  func (o *ListRobotOK) String() string {
   110  	return fmt.Sprintf("[GET /robots][%d] listRobotOK  %+v", 200, o.Payload)
   111  }
   112  
   113  func (o *ListRobotOK) GetPayload() []*models.Robot {
   114  	return o.Payload
   115  }
   116  
   117  func (o *ListRobotOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   118  
   119  	// hydrates response header Link
   120  	hdrLink := response.GetHeader("Link")
   121  
   122  	if hdrLink != "" {
   123  		o.Link = hdrLink
   124  	}
   125  
   126  	// hydrates response header X-Total-Count
   127  	hdrXTotalCount := response.GetHeader("X-Total-Count")
   128  
   129  	if hdrXTotalCount != "" {
   130  		valxTotalCount, err := swag.ConvertInt64(hdrXTotalCount)
   131  		if err != nil {
   132  			return errors.InvalidType("X-Total-Count", "header", "int64", hdrXTotalCount)
   133  		}
   134  		o.XTotalCount = valxTotalCount
   135  	}
   136  
   137  	// response payload
   138  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
   139  		return err
   140  	}
   141  
   142  	return nil
   143  }
   144  
   145  // NewListRobotBadRequest creates a ListRobotBadRequest with default headers values
   146  func NewListRobotBadRequest() *ListRobotBadRequest {
   147  	return &ListRobotBadRequest{}
   148  }
   149  
   150  /*
   151  ListRobotBadRequest describes a response with status code 400, with default header values.
   152  
   153  Bad request
   154  */
   155  type ListRobotBadRequest struct {
   156  
   157  	/* The ID of the corresponding request for the response
   158  	 */
   159  	XRequestID string
   160  
   161  	Payload *models.Errors
   162  }
   163  
   164  // IsSuccess returns true when this list robot bad request response has a 2xx status code
   165  func (o *ListRobotBadRequest) IsSuccess() bool {
   166  	return false
   167  }
   168  
   169  // IsRedirect returns true when this list robot bad request response has a 3xx status code
   170  func (o *ListRobotBadRequest) IsRedirect() bool {
   171  	return false
   172  }
   173  
   174  // IsClientError returns true when this list robot bad request response has a 4xx status code
   175  func (o *ListRobotBadRequest) IsClientError() bool {
   176  	return true
   177  }
   178  
   179  // IsServerError returns true when this list robot bad request response has a 5xx status code
   180  func (o *ListRobotBadRequest) IsServerError() bool {
   181  	return false
   182  }
   183  
   184  // IsCode returns true when this list robot bad request response a status code equal to that given
   185  func (o *ListRobotBadRequest) IsCode(code int) bool {
   186  	return code == 400
   187  }
   188  
   189  func (o *ListRobotBadRequest) Error() string {
   190  	return fmt.Sprintf("[GET /robots][%d] listRobotBadRequest  %+v", 400, o.Payload)
   191  }
   192  
   193  func (o *ListRobotBadRequest) String() string {
   194  	return fmt.Sprintf("[GET /robots][%d] listRobotBadRequest  %+v", 400, o.Payload)
   195  }
   196  
   197  func (o *ListRobotBadRequest) GetPayload() *models.Errors {
   198  	return o.Payload
   199  }
   200  
   201  func (o *ListRobotBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   202  
   203  	// hydrates response header X-Request-Id
   204  	hdrXRequestID := response.GetHeader("X-Request-Id")
   205  
   206  	if hdrXRequestID != "" {
   207  		o.XRequestID = hdrXRequestID
   208  	}
   209  
   210  	o.Payload = new(models.Errors)
   211  
   212  	// response payload
   213  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   214  		return err
   215  	}
   216  
   217  	return nil
   218  }
   219  
   220  // NewListRobotNotFound creates a ListRobotNotFound with default headers values
   221  func NewListRobotNotFound() *ListRobotNotFound {
   222  	return &ListRobotNotFound{}
   223  }
   224  
   225  /*
   226  ListRobotNotFound describes a response with status code 404, with default header values.
   227  
   228  Not found
   229  */
   230  type ListRobotNotFound struct {
   231  
   232  	/* The ID of the corresponding request for the response
   233  	 */
   234  	XRequestID string
   235  
   236  	Payload *models.Errors
   237  }
   238  
   239  // IsSuccess returns true when this list robot not found response has a 2xx status code
   240  func (o *ListRobotNotFound) IsSuccess() bool {
   241  	return false
   242  }
   243  
   244  // IsRedirect returns true when this list robot not found response has a 3xx status code
   245  func (o *ListRobotNotFound) IsRedirect() bool {
   246  	return false
   247  }
   248  
   249  // IsClientError returns true when this list robot not found response has a 4xx status code
   250  func (o *ListRobotNotFound) IsClientError() bool {
   251  	return true
   252  }
   253  
   254  // IsServerError returns true when this list robot not found response has a 5xx status code
   255  func (o *ListRobotNotFound) IsServerError() bool {
   256  	return false
   257  }
   258  
   259  // IsCode returns true when this list robot not found response a status code equal to that given
   260  func (o *ListRobotNotFound) IsCode(code int) bool {
   261  	return code == 404
   262  }
   263  
   264  func (o *ListRobotNotFound) Error() string {
   265  	return fmt.Sprintf("[GET /robots][%d] listRobotNotFound  %+v", 404, o.Payload)
   266  }
   267  
   268  func (o *ListRobotNotFound) String() string {
   269  	return fmt.Sprintf("[GET /robots][%d] listRobotNotFound  %+v", 404, o.Payload)
   270  }
   271  
   272  func (o *ListRobotNotFound) GetPayload() *models.Errors {
   273  	return o.Payload
   274  }
   275  
   276  func (o *ListRobotNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   277  
   278  	// hydrates response header X-Request-Id
   279  	hdrXRequestID := response.GetHeader("X-Request-Id")
   280  
   281  	if hdrXRequestID != "" {
   282  		o.XRequestID = hdrXRequestID
   283  	}
   284  
   285  	o.Payload = new(models.Errors)
   286  
   287  	// response payload
   288  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   289  		return err
   290  	}
   291  
   292  	return nil
   293  }
   294  
   295  // NewListRobotInternalServerError creates a ListRobotInternalServerError with default headers values
   296  func NewListRobotInternalServerError() *ListRobotInternalServerError {
   297  	return &ListRobotInternalServerError{}
   298  }
   299  
   300  /*
   301  ListRobotInternalServerError describes a response with status code 500, with default header values.
   302  
   303  Internal server error
   304  */
   305  type ListRobotInternalServerError struct {
   306  
   307  	/* The ID of the corresponding request for the response
   308  	 */
   309  	XRequestID string
   310  
   311  	Payload *models.Errors
   312  }
   313  
   314  // IsSuccess returns true when this list robot internal server error response has a 2xx status code
   315  func (o *ListRobotInternalServerError) IsSuccess() bool {
   316  	return false
   317  }
   318  
   319  // IsRedirect returns true when this list robot internal server error response has a 3xx status code
   320  func (o *ListRobotInternalServerError) IsRedirect() bool {
   321  	return false
   322  }
   323  
   324  // IsClientError returns true when this list robot internal server error response has a 4xx status code
   325  func (o *ListRobotInternalServerError) IsClientError() bool {
   326  	return false
   327  }
   328  
   329  // IsServerError returns true when this list robot internal server error response has a 5xx status code
   330  func (o *ListRobotInternalServerError) IsServerError() bool {
   331  	return true
   332  }
   333  
   334  // IsCode returns true when this list robot internal server error response a status code equal to that given
   335  func (o *ListRobotInternalServerError) IsCode(code int) bool {
   336  	return code == 500
   337  }
   338  
   339  func (o *ListRobotInternalServerError) Error() string {
   340  	return fmt.Sprintf("[GET /robots][%d] listRobotInternalServerError  %+v", 500, o.Payload)
   341  }
   342  
   343  func (o *ListRobotInternalServerError) String() string {
   344  	return fmt.Sprintf("[GET /robots][%d] listRobotInternalServerError  %+v", 500, o.Payload)
   345  }
   346  
   347  func (o *ListRobotInternalServerError) GetPayload() *models.Errors {
   348  	return o.Payload
   349  }
   350  
   351  func (o *ListRobotInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   352  
   353  	// hydrates response header X-Request-Id
   354  	hdrXRequestID := response.GetHeader("X-Request-Id")
   355  
   356  	if hdrXRequestID != "" {
   357  		o.XRequestID = hdrXRequestID
   358  	}
   359  
   360  	o.Payload = new(models.Errors)
   361  
   362  	// response payload
   363  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   364  		return err
   365  	}
   366  
   367  	return nil
   368  }