Add API, CLI and web UI integration for objects

This change adds the API endpoints, the CLI commands and the web UI elements
needed to manage objects in GARMs internal storage.

This storage system is meant to be used to distribute the garm-agent and as a
single source of truth for provider binaries, when we will add the ability for GARM
to scale out.

Potentially, we can also use this in air gapped systems to distribute the runner binaries
for forges that don't have their own internal storage system (like GHES).

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2025-10-07 17:07:40 +00:00 committed by Gabriel
parent f66f95baff
commit 6c46cf9be1
138 changed files with 7911 additions and 267 deletions

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package objects
// 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"
)
// NewDeleteFileObjectParams creates a new DeleteFileObjectParams 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 NewDeleteFileObjectParams() *DeleteFileObjectParams {
return &DeleteFileObjectParams{
timeout: cr.DefaultTimeout,
}
}
// NewDeleteFileObjectParamsWithTimeout creates a new DeleteFileObjectParams object
// with the ability to set a timeout on a request.
func NewDeleteFileObjectParamsWithTimeout(timeout time.Duration) *DeleteFileObjectParams {
return &DeleteFileObjectParams{
timeout: timeout,
}
}
// NewDeleteFileObjectParamsWithContext creates a new DeleteFileObjectParams object
// with the ability to set a context for a request.
func NewDeleteFileObjectParamsWithContext(ctx context.Context) *DeleteFileObjectParams {
return &DeleteFileObjectParams{
Context: ctx,
}
}
// NewDeleteFileObjectParamsWithHTTPClient creates a new DeleteFileObjectParams object
// with the ability to set a custom HTTPClient for a request.
func NewDeleteFileObjectParamsWithHTTPClient(client *http.Client) *DeleteFileObjectParams {
return &DeleteFileObjectParams{
HTTPClient: client,
}
}
/*
DeleteFileObjectParams contains all the parameters to send to the API endpoint
for the delete file object operation.
Typically these are written to a http.Request.
*/
type DeleteFileObjectParams struct {
/* ObjectID.
The ID of the file object.
*/
ObjectID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the delete file object params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteFileObjectParams) WithDefaults() *DeleteFileObjectParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the delete file object params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteFileObjectParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the delete file object params
func (o *DeleteFileObjectParams) WithTimeout(timeout time.Duration) *DeleteFileObjectParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the delete file object params
func (o *DeleteFileObjectParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the delete file object params
func (o *DeleteFileObjectParams) WithContext(ctx context.Context) *DeleteFileObjectParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the delete file object params
func (o *DeleteFileObjectParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the delete file object params
func (o *DeleteFileObjectParams) WithHTTPClient(client *http.Client) *DeleteFileObjectParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the delete file object params
func (o *DeleteFileObjectParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithObjectID adds the objectID to the delete file object params
func (o *DeleteFileObjectParams) WithObjectID(objectID string) *DeleteFileObjectParams {
o.SetObjectID(objectID)
return o
}
// SetObjectID adds the objectId to the delete file object params
func (o *DeleteFileObjectParams) SetObjectID(objectID string) {
o.ObjectID = objectID
}
// WriteToRequest writes these params to a swagger request
func (o *DeleteFileObjectParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param objectID
if err := r.SetPathParam("objectID", o.ObjectID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,106 @@
// Code generated by go-swagger; DO NOT EDIT.
package objects
// 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"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
)
// DeleteFileObjectReader is a Reader for the DeleteFileObject structure.
type DeleteFileObjectReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *DeleteFileObjectReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
result := NewDeleteFileObjectDefault(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
}
// NewDeleteFileObjectDefault creates a DeleteFileObjectDefault with default headers values
func NewDeleteFileObjectDefault(code int) *DeleteFileObjectDefault {
return &DeleteFileObjectDefault{
_statusCode: code,
}
}
/*
DeleteFileObjectDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type DeleteFileObjectDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this delete file object default response has a 2xx status code
func (o *DeleteFileObjectDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this delete file object default response has a 3xx status code
func (o *DeleteFileObjectDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this delete file object default response has a 4xx status code
func (o *DeleteFileObjectDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this delete file object default response has a 5xx status code
func (o *DeleteFileObjectDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this delete file object default response a status code equal to that given
func (o *DeleteFileObjectDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the delete file object default response
func (o *DeleteFileObjectDefault) Code() int {
return o._statusCode
}
func (o *DeleteFileObjectDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[DELETE /objects/{objectID}][%d] DeleteFileObject default %s", o._statusCode, payload)
}
func (o *DeleteFileObjectDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[DELETE /objects/{objectID}][%d] DeleteFileObject default %s", o._statusCode, payload)
}
func (o *DeleteFileObjectDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *DeleteFileObjectDefault) 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 objects
// 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"
)
// NewGetFileObjectParams creates a new GetFileObjectParams 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 NewGetFileObjectParams() *GetFileObjectParams {
return &GetFileObjectParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetFileObjectParamsWithTimeout creates a new GetFileObjectParams object
// with the ability to set a timeout on a request.
func NewGetFileObjectParamsWithTimeout(timeout time.Duration) *GetFileObjectParams {
return &GetFileObjectParams{
timeout: timeout,
}
}
// NewGetFileObjectParamsWithContext creates a new GetFileObjectParams object
// with the ability to set a context for a request.
func NewGetFileObjectParamsWithContext(ctx context.Context) *GetFileObjectParams {
return &GetFileObjectParams{
Context: ctx,
}
}
// NewGetFileObjectParamsWithHTTPClient creates a new GetFileObjectParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetFileObjectParamsWithHTTPClient(client *http.Client) *GetFileObjectParams {
return &GetFileObjectParams{
HTTPClient: client,
}
}
/*
GetFileObjectParams contains all the parameters to send to the API endpoint
for the get file object operation.
Typically these are written to a http.Request.
*/
type GetFileObjectParams struct {
/* ObjectID.
The ID of the file object.
*/
ObjectID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the get file object params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetFileObjectParams) WithDefaults() *GetFileObjectParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the get file object params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetFileObjectParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the get file object params
func (o *GetFileObjectParams) WithTimeout(timeout time.Duration) *GetFileObjectParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get file object params
func (o *GetFileObjectParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get file object params
func (o *GetFileObjectParams) WithContext(ctx context.Context) *GetFileObjectParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get file object params
func (o *GetFileObjectParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get file object params
func (o *GetFileObjectParams) WithHTTPClient(client *http.Client) *GetFileObjectParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get file object params
func (o *GetFileObjectParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithObjectID adds the objectID to the get file object params
func (o *GetFileObjectParams) WithObjectID(objectID string) *GetFileObjectParams {
o.SetObjectID(objectID)
return o
}
// SetObjectID adds the objectId to the get file object params
func (o *GetFileObjectParams) SetObjectID(objectID string) {
o.ObjectID = objectID
}
// WriteToRequest writes these params to a swagger request
func (o *GetFileObjectParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param objectID
if err := r.SetPathParam("objectID", o.ObjectID); 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 objects
// 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"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// GetFileObjectReader is a Reader for the GetFileObject structure.
type GetFileObjectReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetFileObjectReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetFileObjectOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewGetFileObjectBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("[GET /objects/{objectID}] GetFileObject", response, response.Code())
}
}
// NewGetFileObjectOK creates a GetFileObjectOK with default headers values
func NewGetFileObjectOK() *GetFileObjectOK {
return &GetFileObjectOK{}
}
/*
GetFileObjectOK describes a response with status code 200, with default header values.
FileObject
*/
type GetFileObjectOK struct {
Payload garm_params.FileObject
}
// IsSuccess returns true when this get file object o k response has a 2xx status code
func (o *GetFileObjectOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get file object o k response has a 3xx status code
func (o *GetFileObjectOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get file object o k response has a 4xx status code
func (o *GetFileObjectOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get file object o k response has a 5xx status code
func (o *GetFileObjectOK) IsServerError() bool {
return false
}
// IsCode returns true when this get file object o k response a status code equal to that given
func (o *GetFileObjectOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the get file object o k response
func (o *GetFileObjectOK) Code() int {
return 200
}
func (o *GetFileObjectOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /objects/{objectID}][%d] getFileObjectOK %s", 200, payload)
}
func (o *GetFileObjectOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /objects/{objectID}][%d] getFileObjectOK %s", 200, payload)
}
func (o *GetFileObjectOK) GetPayload() garm_params.FileObject {
return o.Payload
}
func (o *GetFileObjectOK) 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
}
// NewGetFileObjectBadRequest creates a GetFileObjectBadRequest with default headers values
func NewGetFileObjectBadRequest() *GetFileObjectBadRequest {
return &GetFileObjectBadRequest{}
}
/*
GetFileObjectBadRequest describes a response with status code 400, with default header values.
APIErrorResponse
*/
type GetFileObjectBadRequest struct {
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this get file object bad request response has a 2xx status code
func (o *GetFileObjectBadRequest) IsSuccess() bool {
return false
}
// IsRedirect returns true when this get file object bad request response has a 3xx status code
func (o *GetFileObjectBadRequest) IsRedirect() bool {
return false
}
// IsClientError returns true when this get file object bad request response has a 4xx status code
func (o *GetFileObjectBadRequest) IsClientError() bool {
return true
}
// IsServerError returns true when this get file object bad request response has a 5xx status code
func (o *GetFileObjectBadRequest) IsServerError() bool {
return false
}
// IsCode returns true when this get file object bad request response a status code equal to that given
func (o *GetFileObjectBadRequest) IsCode(code int) bool {
return code == 400
}
// Code gets the status code for the get file object bad request response
func (o *GetFileObjectBadRequest) Code() int {
return 400
}
func (o *GetFileObjectBadRequest) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /objects/{objectID}][%d] getFileObjectBadRequest %s", 400, payload)
}
func (o *GetFileObjectBadRequest) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /objects/{objectID}][%d] getFileObjectBadRequest %s", 400, payload)
}
func (o *GetFileObjectBadRequest) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *GetFileObjectBadRequest) 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,232 @@
// Code generated by go-swagger; DO NOT EDIT.
package objects
// 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"
"github.com/go-openapi/swag"
)
// NewListFileObjectsParams creates a new ListFileObjectsParams 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 NewListFileObjectsParams() *ListFileObjectsParams {
return &ListFileObjectsParams{
timeout: cr.DefaultTimeout,
}
}
// NewListFileObjectsParamsWithTimeout creates a new ListFileObjectsParams object
// with the ability to set a timeout on a request.
func NewListFileObjectsParamsWithTimeout(timeout time.Duration) *ListFileObjectsParams {
return &ListFileObjectsParams{
timeout: timeout,
}
}
// NewListFileObjectsParamsWithContext creates a new ListFileObjectsParams object
// with the ability to set a context for a request.
func NewListFileObjectsParamsWithContext(ctx context.Context) *ListFileObjectsParams {
return &ListFileObjectsParams{
Context: ctx,
}
}
// NewListFileObjectsParamsWithHTTPClient creates a new ListFileObjectsParams object
// with the ability to set a custom HTTPClient for a request.
func NewListFileObjectsParamsWithHTTPClient(client *http.Client) *ListFileObjectsParams {
return &ListFileObjectsParams{
HTTPClient: client,
}
}
/*
ListFileObjectsParams contains all the parameters to send to the API endpoint
for the list file objects operation.
Typically these are written to a http.Request.
*/
type ListFileObjectsParams struct {
/* Page.
The page at which to list.
*/
Page *int64
/* PageSize.
Number of items per page.
*/
PageSize *int64
/* Tags.
List of tags to filter by.
*/
Tags *string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list file objects params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListFileObjectsParams) WithDefaults() *ListFileObjectsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list file objects params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListFileObjectsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list file objects params
func (o *ListFileObjectsParams) WithTimeout(timeout time.Duration) *ListFileObjectsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list file objects params
func (o *ListFileObjectsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list file objects params
func (o *ListFileObjectsParams) WithContext(ctx context.Context) *ListFileObjectsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list file objects params
func (o *ListFileObjectsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list file objects params
func (o *ListFileObjectsParams) WithHTTPClient(client *http.Client) *ListFileObjectsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list file objects params
func (o *ListFileObjectsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithPage adds the page to the list file objects params
func (o *ListFileObjectsParams) WithPage(page *int64) *ListFileObjectsParams {
o.SetPage(page)
return o
}
// SetPage adds the page to the list file objects params
func (o *ListFileObjectsParams) SetPage(page *int64) {
o.Page = page
}
// WithPageSize adds the pageSize to the list file objects params
func (o *ListFileObjectsParams) WithPageSize(pageSize *int64) *ListFileObjectsParams {
o.SetPageSize(pageSize)
return o
}
// SetPageSize adds the pageSize to the list file objects params
func (o *ListFileObjectsParams) SetPageSize(pageSize *int64) {
o.PageSize = pageSize
}
// WithTags adds the tags to the list file objects params
func (o *ListFileObjectsParams) WithTags(tags *string) *ListFileObjectsParams {
o.SetTags(tags)
return o
}
// SetTags adds the tags to the list file objects params
func (o *ListFileObjectsParams) SetTags(tags *string) {
o.Tags = tags
}
// WriteToRequest writes these params to a swagger request
func (o *ListFileObjectsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if o.Page != nil {
// query param page
var qrPage int64
if o.Page != nil {
qrPage = *o.Page
}
qPage := swag.FormatInt64(qrPage)
if qPage != "" {
if err := r.SetQueryParam("page", qPage); err != nil {
return err
}
}
}
if o.PageSize != nil {
// query param pageSize
var qrPageSize int64
if o.PageSize != nil {
qrPageSize = *o.PageSize
}
qPageSize := swag.FormatInt64(qrPageSize)
if qPageSize != "" {
if err := r.SetQueryParam("pageSize", qPageSize); err != nil {
return err
}
}
}
if o.Tags != nil {
// query param tags
var qrTags string
if o.Tags != nil {
qrTags = *o.Tags
}
qTags := qrTags
if qTags != "" {
if err := r.SetQueryParam("tags", qTags); 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 objects
// 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"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListFileObjectsReader is a Reader for the ListFileObjects structure.
type ListFileObjectsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListFileObjectsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListFileObjectsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewListFileObjectsBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("[GET /objects] ListFileObjects", response, response.Code())
}
}
// NewListFileObjectsOK creates a ListFileObjectsOK with default headers values
func NewListFileObjectsOK() *ListFileObjectsOK {
return &ListFileObjectsOK{}
}
/*
ListFileObjectsOK describes a response with status code 200, with default header values.
FileObjectPaginatedResponse
*/
type ListFileObjectsOK struct {
Payload garm_params.FileObjectPaginatedResponse
}
// IsSuccess returns true when this list file objects o k response has a 2xx status code
func (o *ListFileObjectsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list file objects o k response has a 3xx status code
func (o *ListFileObjectsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list file objects o k response has a 4xx status code
func (o *ListFileObjectsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list file objects o k response has a 5xx status code
func (o *ListFileObjectsOK) IsServerError() bool {
return false
}
// IsCode returns true when this list file objects o k response a status code equal to that given
func (o *ListFileObjectsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list file objects o k response
func (o *ListFileObjectsOK) Code() int {
return 200
}
func (o *ListFileObjectsOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /objects][%d] listFileObjectsOK %s", 200, payload)
}
func (o *ListFileObjectsOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /objects][%d] listFileObjectsOK %s", 200, payload)
}
func (o *ListFileObjectsOK) GetPayload() garm_params.FileObjectPaginatedResponse {
return o.Payload
}
func (o *ListFileObjectsOK) 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
}
// NewListFileObjectsBadRequest creates a ListFileObjectsBadRequest with default headers values
func NewListFileObjectsBadRequest() *ListFileObjectsBadRequest {
return &ListFileObjectsBadRequest{}
}
/*
ListFileObjectsBadRequest describes a response with status code 400, with default header values.
APIErrorResponse
*/
type ListFileObjectsBadRequest struct {
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list file objects bad request response has a 2xx status code
func (o *ListFileObjectsBadRequest) IsSuccess() bool {
return false
}
// IsRedirect returns true when this list file objects bad request response has a 3xx status code
func (o *ListFileObjectsBadRequest) IsRedirect() bool {
return false
}
// IsClientError returns true when this list file objects bad request response has a 4xx status code
func (o *ListFileObjectsBadRequest) IsClientError() bool {
return true
}
// IsServerError returns true when this list file objects bad request response has a 5xx status code
func (o *ListFileObjectsBadRequest) IsServerError() bool {
return false
}
// IsCode returns true when this list file objects bad request response a status code equal to that given
func (o *ListFileObjectsBadRequest) IsCode(code int) bool {
return code == 400
}
// Code gets the status code for the list file objects bad request response
func (o *ListFileObjectsBadRequest) Code() int {
return 400
}
func (o *ListFileObjectsBadRequest) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /objects][%d] listFileObjectsBadRequest %s", 400, payload)
}
func (o *ListFileObjectsBadRequest) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /objects][%d] listFileObjectsBadRequest %s", 400, payload)
}
func (o *ListFileObjectsBadRequest) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListFileObjectsBadRequest) 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,222 @@
// Code generated by go-swagger; DO NOT EDIT.
package objects
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// New creates a new objects API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
// New creates a new objects API client with basic auth credentials.
// It takes the following parameters:
// - host: http host (github.com).
// - basePath: any base path for the API client ("/v1", "/v3").
// - scheme: http scheme ("http", "https").
// - user: user for basic authentication header.
// - password: password for basic authentication header.
func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService {
transport := httptransport.New(host, basePath, []string{scheme})
transport.DefaultAuthentication = httptransport.BasicAuth(user, password)
return &Client{transport: transport, formats: strfmt.Default}
}
// New creates a new objects API client with a bearer token for authentication.
// It takes the following parameters:
// - host: http host (github.com).
// - basePath: any base path for the API client ("/v1", "/v3").
// - scheme: http scheme ("http", "https").
// - bearerToken: bearer token for Bearer authentication header.
func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService {
transport := httptransport.New(host, basePath, []string{scheme})
transport.DefaultAuthentication = httptransport.BearerToken(bearerToken)
return &Client{transport: transport, formats: strfmt.Default}
}
/*
Client for objects API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
// ClientOption may be used to customize the behavior of Client methods.
type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
DeleteFileObject(params *DeleteFileObjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
GetFileObject(params *GetFileObjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetFileObjectOK, error)
ListFileObjects(params *ListFileObjectsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListFileObjectsOK, error)
UpdateFileObject(params *UpdateFileObjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateFileObjectOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
DeleteFileObject deletes a file object
*/
func (a *Client) DeleteFileObject(params *DeleteFileObjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteFileObjectParams()
}
op := &runtime.ClientOperation{
ID: "DeleteFileObject",
Method: "DELETE",
PathPattern: "/objects/{objectID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &DeleteFileObjectReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
_, err := a.transport.Submit(op)
if err != nil {
return err
}
return nil
}
/*
GetFileObject gets a file object
*/
func (a *Client) GetFileObject(params *GetFileObjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetFileObjectOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetFileObjectParams()
}
op := &runtime.ClientOperation{
ID: "GetFileObject",
Method: "GET",
PathPattern: "/objects/{objectID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetFileObjectReader{formats: a.formats},
AuthInfo: authInfo,
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.(*GetFileObjectOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for GetFileObject: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
ListFileObjects lists file objects
*/
func (a *Client) ListFileObjects(params *ListFileObjectsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListFileObjectsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListFileObjectsParams()
}
op := &runtime.ClientOperation{
ID: "ListFileObjects",
Method: "GET",
PathPattern: "/objects",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListFileObjectsReader{formats: a.formats},
AuthInfo: authInfo,
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.(*ListFileObjectsOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for ListFileObjects: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
UpdateFileObject updates a file object
*/
func (a *Client) UpdateFileObject(params *UpdateFileObjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateFileObjectOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewUpdateFileObjectParams()
}
op := &runtime.ClientOperation{
ID: "UpdateFileObject",
Method: "PUT",
PathPattern: "/objects/{objectID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &UpdateFileObjectReader{formats: a.formats},
AuthInfo: authInfo,
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.(*UpdateFileObjectOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for UpdateFileObject: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport
}

View file

@ -0,0 +1,173 @@
// Code generated by go-swagger; DO NOT EDIT.
package objects
// 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"
)
// NewUpdateFileObjectParams creates a new UpdateFileObjectParams 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 NewUpdateFileObjectParams() *UpdateFileObjectParams {
return &UpdateFileObjectParams{
timeout: cr.DefaultTimeout,
}
}
// NewUpdateFileObjectParamsWithTimeout creates a new UpdateFileObjectParams object
// with the ability to set a timeout on a request.
func NewUpdateFileObjectParamsWithTimeout(timeout time.Duration) *UpdateFileObjectParams {
return &UpdateFileObjectParams{
timeout: timeout,
}
}
// NewUpdateFileObjectParamsWithContext creates a new UpdateFileObjectParams object
// with the ability to set a context for a request.
func NewUpdateFileObjectParamsWithContext(ctx context.Context) *UpdateFileObjectParams {
return &UpdateFileObjectParams{
Context: ctx,
}
}
// NewUpdateFileObjectParamsWithHTTPClient creates a new UpdateFileObjectParams object
// with the ability to set a custom HTTPClient for a request.
func NewUpdateFileObjectParamsWithHTTPClient(client *http.Client) *UpdateFileObjectParams {
return &UpdateFileObjectParams{
HTTPClient: client,
}
}
/*
UpdateFileObjectParams contains all the parameters to send to the API endpoint
for the update file object operation.
Typically these are written to a http.Request.
*/
type UpdateFileObjectParams struct {
/* Body.
Parameters used when updating a file object.
*/
Body garm_params.UpdateFileObjectParams
/* ObjectID.
The ID of the file object.
*/
ObjectID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the update file object params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateFileObjectParams) WithDefaults() *UpdateFileObjectParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the update file object params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateFileObjectParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the update file object params
func (o *UpdateFileObjectParams) WithTimeout(timeout time.Duration) *UpdateFileObjectParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the update file object params
func (o *UpdateFileObjectParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the update file object params
func (o *UpdateFileObjectParams) WithContext(ctx context.Context) *UpdateFileObjectParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the update file object params
func (o *UpdateFileObjectParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the update file object params
func (o *UpdateFileObjectParams) WithHTTPClient(client *http.Client) *UpdateFileObjectParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the update file object params
func (o *UpdateFileObjectParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the update file object params
func (o *UpdateFileObjectParams) WithBody(body garm_params.UpdateFileObjectParams) *UpdateFileObjectParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the update file object params
func (o *UpdateFileObjectParams) SetBody(body garm_params.UpdateFileObjectParams) {
o.Body = body
}
// WithObjectID adds the objectID to the update file object params
func (o *UpdateFileObjectParams) WithObjectID(objectID string) *UpdateFileObjectParams {
o.SetObjectID(objectID)
return o
}
// SetObjectID adds the objectId to the update file object params
func (o *UpdateFileObjectParams) SetObjectID(objectID string) {
o.ObjectID = objectID
}
// WriteToRequest writes these params to a swagger request
func (o *UpdateFileObjectParams) 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
}
// path param objectID
if err := r.SetPathParam("objectID", o.ObjectID); 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 objects
// 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"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// UpdateFileObjectReader is a Reader for the UpdateFileObject structure.
type UpdateFileObjectReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *UpdateFileObjectReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewUpdateFileObjectOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewUpdateFileObjectBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("[PUT /objects/{objectID}] UpdateFileObject", response, response.Code())
}
}
// NewUpdateFileObjectOK creates a UpdateFileObjectOK with default headers values
func NewUpdateFileObjectOK() *UpdateFileObjectOK {
return &UpdateFileObjectOK{}
}
/*
UpdateFileObjectOK describes a response with status code 200, with default header values.
FileObject
*/
type UpdateFileObjectOK struct {
Payload garm_params.FileObject
}
// IsSuccess returns true when this update file object o k response has a 2xx status code
func (o *UpdateFileObjectOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this update file object o k response has a 3xx status code
func (o *UpdateFileObjectOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this update file object o k response has a 4xx status code
func (o *UpdateFileObjectOK) IsClientError() bool {
return false
}
// IsServerError returns true when this update file object o k response has a 5xx status code
func (o *UpdateFileObjectOK) IsServerError() bool {
return false
}
// IsCode returns true when this update file object o k response a status code equal to that given
func (o *UpdateFileObjectOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the update file object o k response
func (o *UpdateFileObjectOK) Code() int {
return 200
}
func (o *UpdateFileObjectOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /objects/{objectID}][%d] updateFileObjectOK %s", 200, payload)
}
func (o *UpdateFileObjectOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /objects/{objectID}][%d] updateFileObjectOK %s", 200, payload)
}
func (o *UpdateFileObjectOK) GetPayload() garm_params.FileObject {
return o.Payload
}
func (o *UpdateFileObjectOK) 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
}
// NewUpdateFileObjectBadRequest creates a UpdateFileObjectBadRequest with default headers values
func NewUpdateFileObjectBadRequest() *UpdateFileObjectBadRequest {
return &UpdateFileObjectBadRequest{}
}
/*
UpdateFileObjectBadRequest describes a response with status code 400, with default header values.
APIErrorResponse
*/
type UpdateFileObjectBadRequest struct {
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this update file object bad request response has a 2xx status code
func (o *UpdateFileObjectBadRequest) IsSuccess() bool {
return false
}
// IsRedirect returns true when this update file object bad request response has a 3xx status code
func (o *UpdateFileObjectBadRequest) IsRedirect() bool {
return false
}
// IsClientError returns true when this update file object bad request response has a 4xx status code
func (o *UpdateFileObjectBadRequest) IsClientError() bool {
return true
}
// IsServerError returns true when this update file object bad request response has a 5xx status code
func (o *UpdateFileObjectBadRequest) IsServerError() bool {
return false
}
// IsCode returns true when this update file object bad request response a status code equal to that given
func (o *UpdateFileObjectBadRequest) IsCode(code int) bool {
return code == 400
}
// Code gets the status code for the update file object bad request response
func (o *UpdateFileObjectBadRequest) Code() int {
return 400
}
func (o *UpdateFileObjectBadRequest) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /objects/{objectID}][%d] updateFileObjectBadRequest %s", 400, payload)
}
func (o *UpdateFileObjectBadRequest) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /objects/{objectID}][%d] updateFileObjectBadRequest %s", 400, payload)
}
func (o *UpdateFileObjectBadRequest) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *UpdateFileObjectBadRequest) 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
}