diff --git a/go/models/get_ai_gateway_providers_o_k_body.go b/go/models/get_ai_gateway_providers_o_k_body.go new file mode 100644 index 00000000..d66391ab --- /dev/null +++ b/go/models/get_ai_gateway_providers_o_k_body.go @@ -0,0 +1,76 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// 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/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// GetAiGatewayProvidersOKBody get ai gateway providers o k body +// +// swagger:model getAiGatewayProvidersOKBody +type GetAiGatewayProvidersOKBody struct { + + // providers + Providers map[string]ProviderDefinition `json:"providers,omitempty"` +} + +// Validate validates this get ai gateway providers o k body +func (m *GetAiGatewayProvidersOKBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateProviders(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *GetAiGatewayProvidersOKBody) validateProviders(formats strfmt.Registry) error { + + if swag.IsZero(m.Providers) { // not required + return nil + } + + for k := range m.Providers { + + if err := validate.Required("providers"+"."+k, "body", m.Providers[k]); err != nil { + return err + } + if val, ok := m.Providers[k]; ok { + if err := val.Validate(formats); err != nil { + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *GetAiGatewayProvidersOKBody) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *GetAiGatewayProvidersOKBody) UnmarshalBinary(b []byte) error { + var res GetAiGatewayProvidersOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/go/models/provider_definition.go b/go/models/provider_definition.go new file mode 100644 index 00000000..58ede2c6 --- /dev/null +++ b/go/models/provider_definition.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// 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/strfmt" + "github.com/go-openapi/swag" +) + +// ProviderDefinition provider definition +// +// swagger:model providerDefinition +type ProviderDefinition struct { + + // models + Models []string `json:"models"` + + // token env var + TokenEnvVar string `json:"token_env_var,omitempty"` + + // url env var + URLEnvVar string `json:"url_env_var,omitempty"` +} + +// Validate validates this provider definition +func (m *ProviderDefinition) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ProviderDefinition) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProviderDefinition) UnmarshalBinary(b []byte) error { + var res ProviderDefinition + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/go/plumbing/operations/get_ai_gateway_providers_parameters.go b/go/plumbing/operations/get_ai_gateway_providers_parameters.go new file mode 100644 index 00000000..f8f1d11b --- /dev/null +++ b/go/plumbing/operations/get_ai_gateway_providers_parameters.go @@ -0,0 +1,113 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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" +) + +// NewGetAiGatewayProvidersParams creates a new GetAiGatewayProvidersParams object +// with the default values initialized. +func NewGetAiGatewayProvidersParams() *GetAiGatewayProvidersParams { + + return &GetAiGatewayProvidersParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetAiGatewayProvidersParamsWithTimeout creates a new GetAiGatewayProvidersParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetAiGatewayProvidersParamsWithTimeout(timeout time.Duration) *GetAiGatewayProvidersParams { + + return &GetAiGatewayProvidersParams{ + + timeout: timeout, + } +} + +// NewGetAiGatewayProvidersParamsWithContext creates a new GetAiGatewayProvidersParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetAiGatewayProvidersParamsWithContext(ctx context.Context) *GetAiGatewayProvidersParams { + + return &GetAiGatewayProvidersParams{ + + Context: ctx, + } +} + +// NewGetAiGatewayProvidersParamsWithHTTPClient creates a new GetAiGatewayProvidersParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetAiGatewayProvidersParamsWithHTTPClient(client *http.Client) *GetAiGatewayProvidersParams { + + return &GetAiGatewayProvidersParams{ + HTTPClient: client, + } +} + +/* +GetAiGatewayProvidersParams contains all the parameters to send to the API endpoint +for the get ai gateway providers operation typically these are written to a http.Request +*/ +type GetAiGatewayProvidersParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get ai gateway providers params +func (o *GetAiGatewayProvidersParams) WithTimeout(timeout time.Duration) *GetAiGatewayProvidersParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get ai gateway providers params +func (o *GetAiGatewayProvidersParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get ai gateway providers params +func (o *GetAiGatewayProvidersParams) WithContext(ctx context.Context) *GetAiGatewayProvidersParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get ai gateway providers params +func (o *GetAiGatewayProvidersParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get ai gateway providers params +func (o *GetAiGatewayProvidersParams) WithHTTPClient(client *http.Client) *GetAiGatewayProvidersParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get ai gateway providers params +func (o *GetAiGatewayProvidersParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *GetAiGatewayProvidersParams) 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 +} diff --git a/go/plumbing/operations/get_ai_gateway_providers_responses.go b/go/plumbing/operations/get_ai_gateway_providers_responses.go new file mode 100644 index 00000000..0038ff04 --- /dev/null +++ b/go/plumbing/operations/get_ai_gateway_providers_responses.go @@ -0,0 +1,70 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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" + + "github.com/netlify/open-api/v2/go/models" +) + +// GetAiGatewayProvidersReader is a Reader for the GetAiGatewayProviders structure. +type GetAiGatewayProvidersReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetAiGatewayProvidersReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetAiGatewayProvidersOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewGetAiGatewayProvidersOK creates a GetAiGatewayProvidersOK with default headers values +func NewGetAiGatewayProvidersOK() *GetAiGatewayProvidersOK { + return &GetAiGatewayProvidersOK{} +} + +/* +GetAiGatewayProvidersOK handles this case with default header values. + +The mapping of providers and supported models +*/ +type GetAiGatewayProvidersOK struct { + Payload *models.GetAiGatewayProvidersOKBody +} + +func (o *GetAiGatewayProvidersOK) Error() string { + return fmt.Sprintf("[GET /ai-gateway/providers][%d] getAiGatewayProvidersOK %+v", 200, o.Payload) +} + +func (o *GetAiGatewayProvidersOK) GetPayload() *models.GetAiGatewayProvidersOKBody { + return o.Payload +} + +func (o *GetAiGatewayProvidersOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.GetAiGatewayProvidersOKBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/go/plumbing/operations/operations_client.go b/go/plumbing/operations/operations_client.go index b9353d48..8685a2c7 100644 --- a/go/plumbing/operations/operations_client.go +++ b/go/plumbing/operations/operations_client.go @@ -27,6 +27,8 @@ type Client struct { // ClientService is the interface for Client methods type ClientService interface { + GetAiGatewayProviders(params *GetAiGatewayProvidersParams, authInfo runtime.ClientAuthInfoWriter) (*GetAiGatewayProvidersOK, error) + AddMemberToAccount(params *AddMemberToAccountParams, authInfo runtime.ClientAuthInfoWriter) (*AddMemberToAccountOK, error) CancelAccount(params *CancelAccountParams, authInfo runtime.ClientAuthInfoWriter) (*CancelAccountNoContent, error) @@ -300,6 +302,41 @@ type ClientService interface { SetTransport(transport runtime.ClientTransport) } +/* +GetAiGatewayProviders get ai gateway providers API +*/ +func (a *Client) GetAiGatewayProviders(params *GetAiGatewayProvidersParams, authInfo runtime.ClientAuthInfoWriter) (*GetAiGatewayProvidersOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetAiGatewayProvidersParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "GetAiGatewayProviders", + Method: "GET", + PathPattern: "/ai-gateway/providers", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &GetAiGatewayProvidersReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*GetAiGatewayProvidersOK) + 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 GetAiGatewayProviders: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* AddMemberToAccount add member to account API */ diff --git a/swagger.yml b/swagger.yml index 9c4d42da..f0651fc5 100644 --- a/swagger.yml +++ b/swagger.yml @@ -2752,6 +2752,19 @@ paths: description: No content default: $ref: '#/responses/error' + /ai-gateway/providers: + get: + responses: + '200': + description: The mapping of providers and supported models + schema: + type: object + properties: + providers: + additionalProperties: + type: object + $ref: '#/definitions/providerDefinition' + definitions: DeployValidationsReport: type: object @@ -4114,6 +4127,18 @@ definitions: enum: - new_dev_server - content_refresh + providerDefinition: + type: object + properties: + token_env_var: + type: string + url_env_var: + type: string + models: + type: array + items: + type: string + parameters: page: type: integer