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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package user
     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  // ListUsersReader is a Reader for the ListUsers structure.
    21  type ListUsersReader struct {
    22  	formats strfmt.Registry
    23  }
    24  
    25  // ReadResponse reads a server response into the received o.
    26  func (o *ListUsersReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    27  	switch response.Code() {
    28  	case 200:
    29  		result := NewListUsersOK()
    30  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    31  			return nil, err
    32  		}
    33  		return result, nil
    34  	case 401:
    35  		result := NewListUsersUnauthorized()
    36  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    37  			return nil, err
    38  		}
    39  		return nil, result
    40  	case 403:
    41  		result := NewListUsersForbidden()
    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 := NewListUsersInternalServerError()
    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  // NewListUsersOK creates a ListUsersOK with default headers values
    58  func NewListUsersOK() *ListUsersOK {
    59  	return &ListUsersOK{}
    60  }
    61  
    62  /*
    63  ListUsersOK describes a response with status code 200, with default header values.
    64  
    65  return the list of users.
    66  */
    67  type ListUsersOK struct {
    68  
    69  	/* Link to previous page and next page
    70  	 */
    71  	Link string
    72  
    73  	/* The total count of users
    74  	 */
    75  	XTotalCount int64
    76  
    77  	Payload []*models.UserResp
    78  }
    79  
    80  // IsSuccess returns true when this list users o k response has a 2xx status code
    81  func (o *ListUsersOK) IsSuccess() bool {
    82  	return true
    83  }
    84  
    85  // IsRedirect returns true when this list users o k response has a 3xx status code
    86  func (o *ListUsersOK) IsRedirect() bool {
    87  	return false
    88  }
    89  
    90  // IsClientError returns true when this list users o k response has a 4xx status code
    91  func (o *ListUsersOK) IsClientError() bool {
    92  	return false
    93  }
    94  
    95  // IsServerError returns true when this list users o k response has a 5xx status code
    96  func (o *ListUsersOK) IsServerError() bool {
    97  	return false
    98  }
    99  
   100  // IsCode returns true when this list users o k response a status code equal to that given
   101  func (o *ListUsersOK) IsCode(code int) bool {
   102  	return code == 200
   103  }
   104  
   105  func (o *ListUsersOK) Error() string {
   106  	return fmt.Sprintf("[GET /users][%d] listUsersOK  %+v", 200, o.Payload)
   107  }
   108  
   109  func (o *ListUsersOK) String() string {
   110  	return fmt.Sprintf("[GET /users][%d] listUsersOK  %+v", 200, o.Payload)
   111  }
   112  
   113  func (o *ListUsersOK) GetPayload() []*models.UserResp {
   114  	return o.Payload
   115  }
   116  
   117  func (o *ListUsersOK) 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  // NewListUsersUnauthorized creates a ListUsersUnauthorized with default headers values
   146  func NewListUsersUnauthorized() *ListUsersUnauthorized {
   147  	return &ListUsersUnauthorized{}
   148  }
   149  
   150  /*
   151  ListUsersUnauthorized describes a response with status code 401, with default header values.
   152  
   153  Unauthorized
   154  */
   155  type ListUsersUnauthorized 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 users unauthorized response has a 2xx status code
   165  func (o *ListUsersUnauthorized) IsSuccess() bool {
   166  	return false
   167  }
   168  
   169  // IsRedirect returns true when this list users unauthorized response has a 3xx status code
   170  func (o *ListUsersUnauthorized) IsRedirect() bool {
   171  	return false
   172  }
   173  
   174  // IsClientError returns true when this list users unauthorized response has a 4xx status code
   175  func (o *ListUsersUnauthorized) IsClientError() bool {
   176  	return true
   177  }
   178  
   179  // IsServerError returns true when this list users unauthorized response has a 5xx status code
   180  func (o *ListUsersUnauthorized) IsServerError() bool {
   181  	return false
   182  }
   183  
   184  // IsCode returns true when this list users unauthorized response a status code equal to that given
   185  func (o *ListUsersUnauthorized) IsCode(code int) bool {
   186  	return code == 401
   187  }
   188  
   189  func (o *ListUsersUnauthorized) Error() string {
   190  	return fmt.Sprintf("[GET /users][%d] listUsersUnauthorized  %+v", 401, o.Payload)
   191  }
   192  
   193  func (o *ListUsersUnauthorized) String() string {
   194  	return fmt.Sprintf("[GET /users][%d] listUsersUnauthorized  %+v", 401, o.Payload)
   195  }
   196  
   197  func (o *ListUsersUnauthorized) GetPayload() *models.Errors {
   198  	return o.Payload
   199  }
   200  
   201  func (o *ListUsersUnauthorized) 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  // NewListUsersForbidden creates a ListUsersForbidden with default headers values
   221  func NewListUsersForbidden() *ListUsersForbidden {
   222  	return &ListUsersForbidden{}
   223  }
   224  
   225  /*
   226  ListUsersForbidden describes a response with status code 403, with default header values.
   227  
   228  Forbidden
   229  */
   230  type ListUsersForbidden 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 users forbidden response has a 2xx status code
   240  func (o *ListUsersForbidden) IsSuccess() bool {
   241  	return false
   242  }
   243  
   244  // IsRedirect returns true when this list users forbidden response has a 3xx status code
   245  func (o *ListUsersForbidden) IsRedirect() bool {
   246  	return false
   247  }
   248  
   249  // IsClientError returns true when this list users forbidden response has a 4xx status code
   250  func (o *ListUsersForbidden) IsClientError() bool {
   251  	return true
   252  }
   253  
   254  // IsServerError returns true when this list users forbidden response has a 5xx status code
   255  func (o *ListUsersForbidden) IsServerError() bool {
   256  	return false
   257  }
   258  
   259  // IsCode returns true when this list users forbidden response a status code equal to that given
   260  func (o *ListUsersForbidden) IsCode(code int) bool {
   261  	return code == 403
   262  }
   263  
   264  func (o *ListUsersForbidden) Error() string {
   265  	return fmt.Sprintf("[GET /users][%d] listUsersForbidden  %+v", 403, o.Payload)
   266  }
   267  
   268  func (o *ListUsersForbidden) String() string {
   269  	return fmt.Sprintf("[GET /users][%d] listUsersForbidden  %+v", 403, o.Payload)
   270  }
   271  
   272  func (o *ListUsersForbidden) GetPayload() *models.Errors {
   273  	return o.Payload
   274  }
   275  
   276  func (o *ListUsersForbidden) 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  // NewListUsersInternalServerError creates a ListUsersInternalServerError with default headers values
   296  func NewListUsersInternalServerError() *ListUsersInternalServerError {
   297  	return &ListUsersInternalServerError{}
   298  }
   299  
   300  /*
   301  ListUsersInternalServerError describes a response with status code 500, with default header values.
   302  
   303  Internal server error
   304  */
   305  type ListUsersInternalServerError 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 users internal server error response has a 2xx status code
   315  func (o *ListUsersInternalServerError) IsSuccess() bool {
   316  	return false
   317  }
   318  
   319  // IsRedirect returns true when this list users internal server error response has a 3xx status code
   320  func (o *ListUsersInternalServerError) IsRedirect() bool {
   321  	return false
   322  }
   323  
   324  // IsClientError returns true when this list users internal server error response has a 4xx status code
   325  func (o *ListUsersInternalServerError) IsClientError() bool {
   326  	return false
   327  }
   328  
   329  // IsServerError returns true when this list users internal server error response has a 5xx status code
   330  func (o *ListUsersInternalServerError) IsServerError() bool {
   331  	return true
   332  }
   333  
   334  // IsCode returns true when this list users internal server error response a status code equal to that given
   335  func (o *ListUsersInternalServerError) IsCode(code int) bool {
   336  	return code == 500
   337  }
   338  
   339  func (o *ListUsersInternalServerError) Error() string {
   340  	return fmt.Sprintf("[GET /users][%d] listUsersInternalServerError  %+v", 500, o.Payload)
   341  }
   342  
   343  func (o *ListUsersInternalServerError) String() string {
   344  	return fmt.Sprintf("[GET /users][%d] listUsersInternalServerError  %+v", 500, o.Payload)
   345  }
   346  
   347  func (o *ListUsersInternalServerError) GetPayload() *models.Errors {
   348  	return o.Payload
   349  }
   350  
   351  func (o *ListUsersInternalServerError) 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  }