garm/client/objects/objects_client.go
Gabriel Adrian Samfira 6c46cf9be1 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>
2025-10-08 22:22:58 +03:00

222 lines
7.6 KiB
Go

// 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
}