autogits/bots-common/gitea-generated/client/user/user_create_token_responses.go

263 lines
7.6 KiB
Go
Raw Normal View History

2024-07-07 21:08:41 +02:00
// Code generated by go-swagger; DO NOT EDIT.
package user
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"src.opensuse.org/autogits/common/gitea-generated/models"
)
// UserCreateTokenReader is a Reader for the UserCreateToken structure.
type UserCreateTokenReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *UserCreateTokenReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 201:
result := NewUserCreateTokenCreated()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewUserCreateTokenBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 403:
result := NewUserCreateTokenForbidden()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("[POST /users/{username}/tokens] userCreateToken", response, response.Code())
}
}
// NewUserCreateTokenCreated creates a UserCreateTokenCreated with default headers values
func NewUserCreateTokenCreated() *UserCreateTokenCreated {
return &UserCreateTokenCreated{}
}
/*
UserCreateTokenCreated describes a response with status code 201, with default header values.
AccessToken represents an API access token.
*/
type UserCreateTokenCreated struct {
Payload *models.AccessToken
}
// IsSuccess returns true when this user create token created response has a 2xx status code
func (o *UserCreateTokenCreated) IsSuccess() bool {
return true
}
// IsRedirect returns true when this user create token created response has a 3xx status code
func (o *UserCreateTokenCreated) IsRedirect() bool {
return false
}
// IsClientError returns true when this user create token created response has a 4xx status code
func (o *UserCreateTokenCreated) IsClientError() bool {
return false
}
// IsServerError returns true when this user create token created response has a 5xx status code
func (o *UserCreateTokenCreated) IsServerError() bool {
return false
}
// IsCode returns true when this user create token created response a status code equal to that given
func (o *UserCreateTokenCreated) IsCode(code int) bool {
return code == 201
}
// Code gets the status code for the user create token created response
func (o *UserCreateTokenCreated) Code() int {
return 201
}
func (o *UserCreateTokenCreated) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /users/{username}/tokens][%d] userCreateTokenCreated %s", 201, payload)
}
func (o *UserCreateTokenCreated) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /users/{username}/tokens][%d] userCreateTokenCreated %s", 201, payload)
}
func (o *UserCreateTokenCreated) GetPayload() *models.AccessToken {
return o.Payload
}
func (o *UserCreateTokenCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.AccessToken)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewUserCreateTokenBadRequest creates a UserCreateTokenBadRequest with default headers values
func NewUserCreateTokenBadRequest() *UserCreateTokenBadRequest {
return &UserCreateTokenBadRequest{}
}
/*
UserCreateTokenBadRequest describes a response with status code 400, with default header values.
APIError is error format response
*/
type UserCreateTokenBadRequest struct {
Message string
URL string
}
// IsSuccess returns true when this user create token bad request response has a 2xx status code
func (o *UserCreateTokenBadRequest) IsSuccess() bool {
return false
}
// IsRedirect returns true when this user create token bad request response has a 3xx status code
func (o *UserCreateTokenBadRequest) IsRedirect() bool {
return false
}
// IsClientError returns true when this user create token bad request response has a 4xx status code
func (o *UserCreateTokenBadRequest) IsClientError() bool {
return true
}
// IsServerError returns true when this user create token bad request response has a 5xx status code
func (o *UserCreateTokenBadRequest) IsServerError() bool {
return false
}
// IsCode returns true when this user create token bad request response a status code equal to that given
func (o *UserCreateTokenBadRequest) IsCode(code int) bool {
return code == 400
}
// Code gets the status code for the user create token bad request response
func (o *UserCreateTokenBadRequest) Code() int {
return 400
}
func (o *UserCreateTokenBadRequest) Error() string {
return fmt.Sprintf("[POST /users/{username}/tokens][%d] userCreateTokenBadRequest", 400)
}
func (o *UserCreateTokenBadRequest) String() string {
return fmt.Sprintf("[POST /users/{username}/tokens][%d] userCreateTokenBadRequest", 400)
}
func (o *UserCreateTokenBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// hydrates response header message
hdrMessage := response.GetHeader("message")
if hdrMessage != "" {
o.Message = hdrMessage
}
// hydrates response header url
hdrURL := response.GetHeader("url")
if hdrURL != "" {
o.URL = hdrURL
}
return nil
}
// NewUserCreateTokenForbidden creates a UserCreateTokenForbidden with default headers values
func NewUserCreateTokenForbidden() *UserCreateTokenForbidden {
return &UserCreateTokenForbidden{}
}
/*
UserCreateTokenForbidden describes a response with status code 403, with default header values.
APIForbiddenError is a forbidden error response
*/
type UserCreateTokenForbidden struct {
Message string
URL string
}
// IsSuccess returns true when this user create token forbidden response has a 2xx status code
func (o *UserCreateTokenForbidden) IsSuccess() bool {
return false
}
// IsRedirect returns true when this user create token forbidden response has a 3xx status code
func (o *UserCreateTokenForbidden) IsRedirect() bool {
return false
}
// IsClientError returns true when this user create token forbidden response has a 4xx status code
func (o *UserCreateTokenForbidden) IsClientError() bool {
return true
}
// IsServerError returns true when this user create token forbidden response has a 5xx status code
func (o *UserCreateTokenForbidden) IsServerError() bool {
return false
}
// IsCode returns true when this user create token forbidden response a status code equal to that given
func (o *UserCreateTokenForbidden) IsCode(code int) bool {
return code == 403
}
// Code gets the status code for the user create token forbidden response
func (o *UserCreateTokenForbidden) Code() int {
return 403
}
func (o *UserCreateTokenForbidden) Error() string {
return fmt.Sprintf("[POST /users/{username}/tokens][%d] userCreateTokenForbidden", 403)
}
func (o *UserCreateTokenForbidden) String() string {
return fmt.Sprintf("[POST /users/{username}/tokens][%d] userCreateTokenForbidden", 403)
}
func (o *UserCreateTokenForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// hydrates response header message
hdrMessage := response.GetHeader("message")
if hdrMessage != "" {
o.Message = hdrMessage
}
// hydrates response header url
hdrURL := response.GetHeader("url")
if hdrURL != "" {
o.URL = hdrURL
}
return nil
}