Generate initial swagger API client library code

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
This commit is contained in:
Ionut Balutoiu 2023-06-30 19:02:44 +03:00 committed by Mihaela Balutoiu
parent d122f293cf
commit 4a68f3b046
447 changed files with 80129 additions and 0 deletions

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewCreateParams creates a new CreateParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewCreateParams() *CreateParams {
return &CreateParams{
timeout: cr.DefaultTimeout,
}
}
// NewCreateParamsWithTimeout creates a new CreateParams object
// with the ability to set a timeout on a request.
func NewCreateParamsWithTimeout(timeout time.Duration) *CreateParams {
return &CreateParams{
timeout: timeout,
}
}
// NewCreateParamsWithContext creates a new CreateParams object
// with the ability to set a context for a request.
func NewCreateParamsWithContext(ctx context.Context) *CreateParams {
return &CreateParams{
Context: ctx,
}
}
// NewCreateParamsWithHTTPClient creates a new CreateParams object
// with the ability to set a custom HTTPClient for a request.
func NewCreateParamsWithHTTPClient(client *http.Client) *CreateParams {
return &CreateParams{
HTTPClient: client,
}
}
/*
CreateParams contains all the parameters to send to the API endpoint
for the create operation.
Typically these are written to a http.Request.
*/
type CreateParams struct {
/* Body.
Parameters used when creating the repository.
*/
Body garm_params.CreateRepoParams
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the create params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateParams) WithDefaults() *CreateParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the create params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the create params
func (o *CreateParams) WithTimeout(timeout time.Duration) *CreateParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the create params
func (o *CreateParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the create params
func (o *CreateParams) WithContext(ctx context.Context) *CreateParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the create params
func (o *CreateParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the create params
func (o *CreateParams) WithHTTPClient(client *http.Client) *CreateParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the create params
func (o *CreateParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the create params
func (o *CreateParams) WithBody(body garm_params.CreateRepoParams) *CreateParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the create params
func (o *CreateParams) SetBody(body garm_params.CreateRepoParams) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *CreateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// CreateReader is a Reader for the Create structure.
type CreateReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *CreateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewCreateOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewCreateDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewCreateOK creates a CreateOK with default headers values
func NewCreateOK() *CreateOK {
return &CreateOK{}
}
/*
CreateOK describes a response with status code 200, with default header values.
Repository
*/
type CreateOK struct {
Payload garm_params.Repository
}
// IsSuccess returns true when this create o k response has a 2xx status code
func (o *CreateOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this create o k response has a 3xx status code
func (o *CreateOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this create o k response has a 4xx status code
func (o *CreateOK) IsClientError() bool {
return false
}
// IsServerError returns true when this create o k response has a 5xx status code
func (o *CreateOK) IsServerError() bool {
return false
}
// IsCode returns true when this create o k response a status code equal to that given
func (o *CreateOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the create o k response
func (o *CreateOK) Code() int {
return 200
}
func (o *CreateOK) Error() string {
return fmt.Sprintf("[POST /repositories][%d] createOK %+v", 200, o.Payload)
}
func (o *CreateOK) String() string {
return fmt.Sprintf("[POST /repositories][%d] createOK %+v", 200, o.Payload)
}
func (o *CreateOK) GetPayload() garm_params.Repository {
return o.Payload
}
func (o *CreateOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewCreateDefault creates a CreateDefault with default headers values
func NewCreateDefault(code int) *CreateDefault {
return &CreateDefault{
_statusCode: code,
}
}
/*
CreateDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type CreateDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this create default response has a 2xx status code
func (o *CreateDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this create default response has a 3xx status code
func (o *CreateDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this create default response has a 4xx status code
func (o *CreateDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this create default response has a 5xx status code
func (o *CreateDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this create default response a status code equal to that given
func (o *CreateDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the create default response
func (o *CreateDefault) Code() int {
return o._statusCode
}
func (o *CreateDefault) Error() string {
return fmt.Sprintf("[POST /repositories][%d] Create default %+v", o._statusCode, o.Payload)
}
func (o *CreateDefault) String() string {
return fmt.Sprintf("[POST /repositories][%d] Create default %+v", o._statusCode, o.Payload)
}
func (o *CreateDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *CreateDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewDeleteParams creates a new DeleteParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewDeleteParams() *DeleteParams {
return &DeleteParams{
timeout: cr.DefaultTimeout,
}
}
// NewDeleteParamsWithTimeout creates a new DeleteParams object
// with the ability to set a timeout on a request.
func NewDeleteParamsWithTimeout(timeout time.Duration) *DeleteParams {
return &DeleteParams{
timeout: timeout,
}
}
// NewDeleteParamsWithContext creates a new DeleteParams object
// with the ability to set a context for a request.
func NewDeleteParamsWithContext(ctx context.Context) *DeleteParams {
return &DeleteParams{
Context: ctx,
}
}
// NewDeleteParamsWithHTTPClient creates a new DeleteParams object
// with the ability to set a custom HTTPClient for a request.
func NewDeleteParamsWithHTTPClient(client *http.Client) *DeleteParams {
return &DeleteParams{
HTTPClient: client,
}
}
/*
DeleteParams contains all the parameters to send to the API endpoint
for the delete operation.
Typically these are written to a http.Request.
*/
type DeleteParams struct {
/* RepoID.
ID of the repository to delete.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the delete params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteParams) WithDefaults() *DeleteParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the delete params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the delete params
func (o *DeleteParams) WithTimeout(timeout time.Duration) *DeleteParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the delete params
func (o *DeleteParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the delete params
func (o *DeleteParams) WithContext(ctx context.Context) *DeleteParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the delete params
func (o *DeleteParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the delete params
func (o *DeleteParams) WithHTTPClient(client *http.Client) *DeleteParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the delete params
func (o *DeleteParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithRepoID adds the repoID to the delete params
func (o *DeleteParams) WithRepoID(repoID string) *DeleteParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the delete params
func (o *DeleteParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *DeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,103 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
)
// DeleteReader is a Reader for the Delete structure.
type DeleteReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *DeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
result := NewDeleteDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
// NewDeleteDefault creates a DeleteDefault with default headers values
func NewDeleteDefault(code int) *DeleteDefault {
return &DeleteDefault{
_statusCode: code,
}
}
/*
DeleteDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type DeleteDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this delete default response has a 2xx status code
func (o *DeleteDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this delete default response has a 3xx status code
func (o *DeleteDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this delete default response has a 4xx status code
func (o *DeleteDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this delete default response has a 5xx status code
func (o *DeleteDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this delete default response a status code equal to that given
func (o *DeleteDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the delete default response
func (o *DeleteDefault) Code() int {
return o._statusCode
}
func (o *DeleteDefault) Error() string {
return fmt.Sprintf("[DELETE /repositories/{repoID}][%d] Delete default %+v", o._statusCode, o.Payload)
}
func (o *DeleteDefault) String() string {
return fmt.Sprintf("[DELETE /repositories/{repoID}][%d] Delete default %+v", o._statusCode, o.Payload)
}
func (o *DeleteDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *DeleteDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewGetParams creates a new GetParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewGetParams() *GetParams {
return &GetParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetParamsWithTimeout creates a new GetParams object
// with the ability to set a timeout on a request.
func NewGetParamsWithTimeout(timeout time.Duration) *GetParams {
return &GetParams{
timeout: timeout,
}
}
// NewGetParamsWithContext creates a new GetParams object
// with the ability to set a context for a request.
func NewGetParamsWithContext(ctx context.Context) *GetParams {
return &GetParams{
Context: ctx,
}
}
// NewGetParamsWithHTTPClient creates a new GetParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetParamsWithHTTPClient(client *http.Client) *GetParams {
return &GetParams{
HTTPClient: client,
}
}
/*
GetParams contains all the parameters to send to the API endpoint
for the get operation.
Typically these are written to a http.Request.
*/
type GetParams struct {
/* RepoID.
ID of the repository to fetch.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the get params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetParams) WithDefaults() *GetParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the get params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the get params
func (o *GetParams) WithTimeout(timeout time.Duration) *GetParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get params
func (o *GetParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get params
func (o *GetParams) WithContext(ctx context.Context) *GetParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get params
func (o *GetParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get params
func (o *GetParams) WithHTTPClient(client *http.Client) *GetParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get params
func (o *GetParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithRepoID adds the repoID to the get params
func (o *GetParams) WithRepoID(repoID string) *GetParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the get params
func (o *GetParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *GetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// GetReader is a Reader for the Get structure.
type GetReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewGetDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewGetOK creates a GetOK with default headers values
func NewGetOK() *GetOK {
return &GetOK{}
}
/*
GetOK describes a response with status code 200, with default header values.
Repository
*/
type GetOK struct {
Payload garm_params.Repository
}
// IsSuccess returns true when this get o k response has a 2xx status code
func (o *GetOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get o k response has a 3xx status code
func (o *GetOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get o k response has a 4xx status code
func (o *GetOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get o k response has a 5xx status code
func (o *GetOK) IsServerError() bool {
return false
}
// IsCode returns true when this get o k response a status code equal to that given
func (o *GetOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the get o k response
func (o *GetOK) Code() int {
return 200
}
func (o *GetOK) Error() string {
return fmt.Sprintf("[GET /repositories/{repoID}][%d] getOK %+v", 200, o.Payload)
}
func (o *GetOK) String() string {
return fmt.Sprintf("[GET /repositories/{repoID}][%d] getOK %+v", 200, o.Payload)
}
func (o *GetOK) GetPayload() garm_params.Repository {
return o.Payload
}
func (o *GetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetDefault creates a GetDefault with default headers values
func NewGetDefault(code int) *GetDefault {
return &GetDefault{
_statusCode: code,
}
}
/*
GetDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type GetDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this get default response has a 2xx status code
func (o *GetDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this get default response has a 3xx status code
func (o *GetDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this get default response has a 4xx status code
func (o *GetDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this get default response has a 5xx status code
func (o *GetDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this get default response a status code equal to that given
func (o *GetDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the get default response
func (o *GetDefault) Code() int {
return o._statusCode
}
func (o *GetDefault) Error() string {
return fmt.Sprintf("[GET /repositories/{repoID}][%d] Get default %+v", o._statusCode, o.Payload)
}
func (o *GetDefault) String() string {
return fmt.Sprintf("[GET /repositories/{repoID}][%d] Get default %+v", o._statusCode, o.Payload)
}
func (o *GetDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *GetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,128 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListParams creates a new ListParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListParams() *ListParams {
return &ListParams{
timeout: cr.DefaultTimeout,
}
}
// NewListParamsWithTimeout creates a new ListParams object
// with the ability to set a timeout on a request.
func NewListParamsWithTimeout(timeout time.Duration) *ListParams {
return &ListParams{
timeout: timeout,
}
}
// NewListParamsWithContext creates a new ListParams object
// with the ability to set a context for a request.
func NewListParamsWithContext(ctx context.Context) *ListParams {
return &ListParams{
Context: ctx,
}
}
// NewListParamsWithHTTPClient creates a new ListParams object
// with the ability to set a custom HTTPClient for a request.
func NewListParamsWithHTTPClient(client *http.Client) *ListParams {
return &ListParams{
HTTPClient: client,
}
}
/*
ListParams contains all the parameters to send to the API endpoint
for the list operation.
Typically these are written to a http.Request.
*/
type ListParams struct {
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListParams) WithDefaults() *ListParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list params
func (o *ListParams) WithTimeout(timeout time.Duration) *ListParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list params
func (o *ListParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list params
func (o *ListParams) WithContext(ctx context.Context) *ListParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list params
func (o *ListParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list params
func (o *ListParams) WithHTTPClient(client *http.Client) *ListParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list params
func (o *ListParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WriteToRequest writes these params to a swagger request
func (o *ListParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListReader is a Reader for the List structure.
type ListReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewListDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewListOK creates a ListOK with default headers values
func NewListOK() *ListOK {
return &ListOK{}
}
/*
ListOK describes a response with status code 200, with default header values.
Repositories
*/
type ListOK struct {
Payload garm_params.Repositories
}
// IsSuccess returns true when this list o k response has a 2xx status code
func (o *ListOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list o k response has a 3xx status code
func (o *ListOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list o k response has a 4xx status code
func (o *ListOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list o k response has a 5xx status code
func (o *ListOK) IsServerError() bool {
return false
}
// IsCode returns true when this list o k response a status code equal to that given
func (o *ListOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list o k response
func (o *ListOK) Code() int {
return 200
}
func (o *ListOK) Error() string {
return fmt.Sprintf("[GET /repositories][%d] listOK %+v", 200, o.Payload)
}
func (o *ListOK) String() string {
return fmt.Sprintf("[GET /repositories][%d] listOK %+v", 200, o.Payload)
}
func (o *ListOK) GetPayload() garm_params.Repositories {
return o.Payload
}
func (o *ListOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListDefault creates a ListDefault with default headers values
func NewListDefault(code int) *ListDefault {
return &ListDefault{
_statusCode: code,
}
}
/*
ListDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type ListDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list default response has a 2xx status code
func (o *ListDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this list default response has a 3xx status code
func (o *ListDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this list default response has a 4xx status code
func (o *ListDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this list default response has a 5xx status code
func (o *ListDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this list default response a status code equal to that given
func (o *ListDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the list default response
func (o *ListDefault) Code() int {
return o._statusCode
}
func (o *ListDefault) Error() string {
return fmt.Sprintf("[GET /repositories][%d] List default %+v", o._statusCode, o.Payload)
}
func (o *ListDefault) String() string {
return fmt.Sprintf("[GET /repositories][%d] List default %+v", o._statusCode, o.Payload)
}
func (o *ListDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,187 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
)
// New creates a new repositories API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
/*
Client for repositories API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
// ClientOption is the option for Client methods
type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
Create(params *CreateParams, opts ...ClientOption) (*CreateOK, error)
Delete(params *DeleteParams, opts ...ClientOption) error
Get(params *GetParams, opts ...ClientOption) (*GetOK, error)
List(params *ListParams, opts ...ClientOption) (*ListOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
Create creates repository with the parameters given
*/
func (a *Client) Create(params *CreateParams, opts ...ClientOption) (*CreateOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateParams()
}
op := &runtime.ClientOperation{
ID: "Create",
Method: "POST",
PathPattern: "/repositories",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &CreateReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*CreateOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*CreateDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
Delete deletes repository by ID
*/
func (a *Client) Delete(params *DeleteParams, opts ...ClientOption) error {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteParams()
}
op := &runtime.ClientOperation{
ID: "Delete",
Method: "DELETE",
PathPattern: "/repositories/{repoID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &DeleteReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
_, err := a.transport.Submit(op)
if err != nil {
return err
}
return nil
}
/*
Get gets repository by ID
*/
func (a *Client) Get(params *GetParams, opts ...ClientOption) (*GetOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetParams()
}
op := &runtime.ClientOperation{
ID: "Get",
Method: "GET",
PathPattern: "/repositories/{repoID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*GetOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*GetDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
List lists repositories
*/
func (a *Client) List(params *ListParams, opts ...ClientOption) (*ListOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListParams()
}
op := &runtime.ClientOperation{
ID: "List",
Method: "GET",
PathPattern: "/repositories",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ListDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport
}