diff --git a/internal/httpclient/client/api/api_client.go b/internal/httpclient/client/api/api_client.go new file mode 100644 index 000000000..d2636d26f --- /dev/null +++ b/internal/httpclient/client/api/api_client.go @@ -0,0 +1,233 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package api + +// 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" + "github.com/go-openapi/strfmt" +) + +// New creates a new api API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for api API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientService is the interface for Client methods +type ClientService interface { + GetRule(params *GetRuleParams) (*GetRuleOK, error) + + GetWellKnownJSONWebKeys(params *GetWellKnownJSONWebKeysParams) (*GetWellKnownJSONWebKeysOK, error) + + ListRules(params *ListRulesParams) (*ListRulesOK, error) + + MakeGenericDecision(params *MakeGenericDecisionParams) (*MakeGenericDecisionOK, error) + + MakeTraefikDecision(params *MakeTraefikDecisionParams) (*MakeTraefikDecisionOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + GetRule retrieves a rule + + Use this method to retrieve a rule from the storage. If it does not exist you will receive a 404 error. +*/ +func (a *Client) GetRule(params *GetRuleParams) (*GetRuleOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetRuleParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getRule", + Method: "GET", + PathPattern: "/rules/{id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetRuleReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*GetRuleOK) + 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 getRule: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + GetWellKnownJSONWebKeys lists cryptographic keys + + This endpoint returns cryptographic keys that are required to, for example, verify signatures of ID Tokens. +*/ +func (a *Client) GetWellKnownJSONWebKeys(params *GetWellKnownJSONWebKeysParams) (*GetWellKnownJSONWebKeysOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetWellKnownJSONWebKeysParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getWellKnownJSONWebKeys", + Method: "GET", + PathPattern: "/.well-known/jwks.json", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetWellKnownJSONWebKeysReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*GetWellKnownJSONWebKeysOK) + 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 getWellKnownJSONWebKeys: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ListRules lists all rules + + This method returns an array of all rules that are stored in the backend. This is useful if you want to get a full +view of what rules you have currently in place. +*/ +func (a *Client) ListRules(params *ListRulesParams) (*ListRulesOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListRulesParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "listRules", + Method: "GET", + PathPattern: "/rules", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ListRulesReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*ListRulesOK) + 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 listRules: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + MakeGenericDecision accesses control generic decision API + + > This endpoint works with all HTTP Methods (GET, POST, PUT, ...) and matches every path prefixed with /decision. + +This endpoint mirrors the proxy capability of ORY Oathkeeper's proxy functionality but instead of forwarding the +request to the upstream server, returns 200 (request should be allowed), 401 (unauthorized), or 403 (forbidden) +status codes. This endpoint can be used to integrate with other API Proxies like Ambassador, Kong, Envoy, and many more. +*/ +func (a *Client) MakeGenericDecision(params *MakeGenericDecisionParams) (*MakeGenericDecisionOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewMakeGenericDecisionParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "makeGenericDecision", + Method: "GET", + PathPattern: "/decisions/generic", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &MakeGenericDecisionReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*MakeGenericDecisionOK) + 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 makeGenericDecision: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + MakeTraefikDecision accesses control decision traefik API + + This endpoint mirrors the proxy capability of ORY Oathkeeper's proxy functionality but instead of forwarding the +request to the upstream server, returns 200 (request should be allowed), 401 (unauthorized), or 403 (forbidden) +status codes. This endpoint can be used to integrate with the Traefik proxy. +*/ +func (a *Client) MakeTraefikDecision(params *MakeTraefikDecisionParams) (*MakeTraefikDecisionOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewMakeTraefikDecisionParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "makeTraefikDecision", + Method: "GET", + PathPattern: "/decisions/traefik", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &MakeTraefikDecisionReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*MakeTraefikDecisionOK) + 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 makeTraefikDecision: 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 +} diff --git a/internal/httpclient/client/api/get_rule_parameters.go b/internal/httpclient/client/api/get_rule_parameters.go new file mode 100644 index 000000000..570a2578f --- /dev/null +++ b/internal/httpclient/client/api/get_rule_parameters.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package api + +// 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" +) + +// NewGetRuleParams creates a new GetRuleParams object +// with the default values initialized. +func NewGetRuleParams() *GetRuleParams { + var () + return &GetRuleParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetRuleParamsWithTimeout creates a new GetRuleParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetRuleParamsWithTimeout(timeout time.Duration) *GetRuleParams { + var () + return &GetRuleParams{ + + timeout: timeout, + } +} + +// NewGetRuleParamsWithContext creates a new GetRuleParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetRuleParamsWithContext(ctx context.Context) *GetRuleParams { + var () + return &GetRuleParams{ + + Context: ctx, + } +} + +// NewGetRuleParamsWithHTTPClient creates a new GetRuleParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetRuleParamsWithHTTPClient(client *http.Client) *GetRuleParams { + var () + return &GetRuleParams{ + HTTPClient: client, + } +} + +/*GetRuleParams contains all the parameters to send to the API endpoint +for the get rule operation typically these are written to a http.Request +*/ +type GetRuleParams struct { + + /*ID*/ + ID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get rule params +func (o *GetRuleParams) WithTimeout(timeout time.Duration) *GetRuleParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get rule params +func (o *GetRuleParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get rule params +func (o *GetRuleParams) WithContext(ctx context.Context) *GetRuleParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get rule params +func (o *GetRuleParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get rule params +func (o *GetRuleParams) WithHTTPClient(client *http.Client) *GetRuleParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get rule params +func (o *GetRuleParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithID adds the id to the get rule params +func (o *GetRuleParams) WithID(id string) *GetRuleParams { + o.SetID(id) + return o +} + +// SetID adds the id to the get rule params +func (o *GetRuleParams) SetID(id string) { + o.ID = id +} + +// WriteToRequest writes these params to a swagger request +func (o *GetRuleParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param id + if err := r.SetPathParam("id", o.ID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/internal/httpclient/client/api/get_rule_responses.go b/internal/httpclient/client/api/get_rule_responses.go new file mode 100644 index 000000000..d4688eea9 --- /dev/null +++ b/internal/httpclient/client/api/get_rule_responses.go @@ -0,0 +1,242 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package api + +// 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/go-openapi/swag" + + "github.com/ory/oathkeeper/internal/httpclient/models" +) + +// GetRuleReader is a Reader for the GetRule structure. +type GetRuleReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetRuleReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetRuleOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 404: + result := NewGetRuleNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetRuleInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewGetRuleOK creates a GetRuleOK with default headers values +func NewGetRuleOK() *GetRuleOK { + return &GetRuleOK{} +} + +/*GetRuleOK handles this case with default header values. + +A rule +*/ +type GetRuleOK struct { + Payload *models.Rule +} + +func (o *GetRuleOK) Error() string { + return fmt.Sprintf("[GET /rules/{id}][%d] getRuleOK %+v", 200, o.Payload) +} + +func (o *GetRuleOK) GetPayload() *models.Rule { + return o.Payload +} + +func (o *GetRuleOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Rule) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetRuleNotFound creates a GetRuleNotFound with default headers values +func NewGetRuleNotFound() *GetRuleNotFound { + return &GetRuleNotFound{} +} + +/*GetRuleNotFound handles this case with default header values. + +The standard error format +*/ +type GetRuleNotFound struct { + Payload *GetRuleNotFoundBody +} + +func (o *GetRuleNotFound) Error() string { + return fmt.Sprintf("[GET /rules/{id}][%d] getRuleNotFound %+v", 404, o.Payload) +} + +func (o *GetRuleNotFound) GetPayload() *GetRuleNotFoundBody { + return o.Payload +} + +func (o *GetRuleNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(GetRuleNotFoundBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetRuleInternalServerError creates a GetRuleInternalServerError with default headers values +func NewGetRuleInternalServerError() *GetRuleInternalServerError { + return &GetRuleInternalServerError{} +} + +/*GetRuleInternalServerError handles this case with default header values. + +The standard error format +*/ +type GetRuleInternalServerError struct { + Payload *GetRuleInternalServerErrorBody +} + +func (o *GetRuleInternalServerError) Error() string { + return fmt.Sprintf("[GET /rules/{id}][%d] getRuleInternalServerError %+v", 500, o.Payload) +} + +func (o *GetRuleInternalServerError) GetPayload() *GetRuleInternalServerErrorBody { + return o.Payload +} + +func (o *GetRuleInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(GetRuleInternalServerErrorBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*GetRuleInternalServerErrorBody get rule internal server error body +swagger:model GetRuleInternalServerErrorBody +*/ +type GetRuleInternalServerErrorBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this get rule internal server error body +func (o *GetRuleInternalServerErrorBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *GetRuleInternalServerErrorBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetRuleInternalServerErrorBody) UnmarshalBinary(b []byte) error { + var res GetRuleInternalServerErrorBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*GetRuleNotFoundBody get rule not found body +swagger:model GetRuleNotFoundBody +*/ +type GetRuleNotFoundBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this get rule not found body +func (o *GetRuleNotFoundBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *GetRuleNotFoundBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetRuleNotFoundBody) UnmarshalBinary(b []byte) error { + var res GetRuleNotFoundBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/internal/httpclient/client/api/get_well_known_json_web_keys_parameters.go b/internal/httpclient/client/api/get_well_known_json_web_keys_parameters.go new file mode 100644 index 000000000..3068e145e --- /dev/null +++ b/internal/httpclient/client/api/get_well_known_json_web_keys_parameters.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package api + +// 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" +) + +// NewGetWellKnownJSONWebKeysParams creates a new GetWellKnownJSONWebKeysParams object +// with the default values initialized. +func NewGetWellKnownJSONWebKeysParams() *GetWellKnownJSONWebKeysParams { + + return &GetWellKnownJSONWebKeysParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetWellKnownJSONWebKeysParamsWithTimeout creates a new GetWellKnownJSONWebKeysParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetWellKnownJSONWebKeysParamsWithTimeout(timeout time.Duration) *GetWellKnownJSONWebKeysParams { + + return &GetWellKnownJSONWebKeysParams{ + + timeout: timeout, + } +} + +// NewGetWellKnownJSONWebKeysParamsWithContext creates a new GetWellKnownJSONWebKeysParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetWellKnownJSONWebKeysParamsWithContext(ctx context.Context) *GetWellKnownJSONWebKeysParams { + + return &GetWellKnownJSONWebKeysParams{ + + Context: ctx, + } +} + +// NewGetWellKnownJSONWebKeysParamsWithHTTPClient creates a new GetWellKnownJSONWebKeysParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetWellKnownJSONWebKeysParamsWithHTTPClient(client *http.Client) *GetWellKnownJSONWebKeysParams { + + return &GetWellKnownJSONWebKeysParams{ + HTTPClient: client, + } +} + +/*GetWellKnownJSONWebKeysParams contains all the parameters to send to the API endpoint +for the get well known JSON web keys operation typically these are written to a http.Request +*/ +type GetWellKnownJSONWebKeysParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get well known JSON web keys params +func (o *GetWellKnownJSONWebKeysParams) WithTimeout(timeout time.Duration) *GetWellKnownJSONWebKeysParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get well known JSON web keys params +func (o *GetWellKnownJSONWebKeysParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get well known JSON web keys params +func (o *GetWellKnownJSONWebKeysParams) WithContext(ctx context.Context) *GetWellKnownJSONWebKeysParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get well known JSON web keys params +func (o *GetWellKnownJSONWebKeysParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get well known JSON web keys params +func (o *GetWellKnownJSONWebKeysParams) WithHTTPClient(client *http.Client) *GetWellKnownJSONWebKeysParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get well known JSON web keys params +func (o *GetWellKnownJSONWebKeysParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *GetWellKnownJSONWebKeysParams) 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/internal/httpclient/client/api/get_well_known_json_web_keys_responses.go b/internal/httpclient/client/api/get_well_known_json_web_keys_responses.go new file mode 100644 index 000000000..c619219c8 --- /dev/null +++ b/internal/httpclient/client/api/get_well_known_json_web_keys_responses.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package api + +// 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/go-openapi/swag" + + "github.com/ory/oathkeeper/internal/httpclient/models" +) + +// GetWellKnownJSONWebKeysReader is a Reader for the GetWellKnownJSONWebKeys structure. +type GetWellKnownJSONWebKeysReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetWellKnownJSONWebKeysReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetWellKnownJSONWebKeysOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewGetWellKnownJSONWebKeysInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewGetWellKnownJSONWebKeysOK creates a GetWellKnownJSONWebKeysOK with default headers values +func NewGetWellKnownJSONWebKeysOK() *GetWellKnownJSONWebKeysOK { + return &GetWellKnownJSONWebKeysOK{} +} + +/*GetWellKnownJSONWebKeysOK handles this case with default header values. + +jsonWebKeySet +*/ +type GetWellKnownJSONWebKeysOK struct { + Payload *models.JSONWebKeySet +} + +func (o *GetWellKnownJSONWebKeysOK) Error() string { + return fmt.Sprintf("[GET /.well-known/jwks.json][%d] getWellKnownJsonWebKeysOK %+v", 200, o.Payload) +} + +func (o *GetWellKnownJSONWebKeysOK) GetPayload() *models.JSONWebKeySet { + return o.Payload +} + +func (o *GetWellKnownJSONWebKeysOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JSONWebKeySet) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetWellKnownJSONWebKeysInternalServerError creates a GetWellKnownJSONWebKeysInternalServerError with default headers values +func NewGetWellKnownJSONWebKeysInternalServerError() *GetWellKnownJSONWebKeysInternalServerError { + return &GetWellKnownJSONWebKeysInternalServerError{} +} + +/*GetWellKnownJSONWebKeysInternalServerError handles this case with default header values. + +The standard error format +*/ +type GetWellKnownJSONWebKeysInternalServerError struct { + Payload *GetWellKnownJSONWebKeysInternalServerErrorBody +} + +func (o *GetWellKnownJSONWebKeysInternalServerError) Error() string { + return fmt.Sprintf("[GET /.well-known/jwks.json][%d] getWellKnownJsonWebKeysInternalServerError %+v", 500, o.Payload) +} + +func (o *GetWellKnownJSONWebKeysInternalServerError) GetPayload() *GetWellKnownJSONWebKeysInternalServerErrorBody { + return o.Payload +} + +func (o *GetWellKnownJSONWebKeysInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(GetWellKnownJSONWebKeysInternalServerErrorBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*GetWellKnownJSONWebKeysInternalServerErrorBody get well known JSON web keys internal server error body +swagger:model GetWellKnownJSONWebKeysInternalServerErrorBody +*/ +type GetWellKnownJSONWebKeysInternalServerErrorBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this get well known JSON web keys internal server error body +func (o *GetWellKnownJSONWebKeysInternalServerErrorBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *GetWellKnownJSONWebKeysInternalServerErrorBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetWellKnownJSONWebKeysInternalServerErrorBody) UnmarshalBinary(b []byte) error { + var res GetWellKnownJSONWebKeysInternalServerErrorBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/internal/httpclient/client/api/list_rules_parameters.go b/internal/httpclient/client/api/list_rules_parameters.go new file mode 100644 index 000000000..cd4f2744b --- /dev/null +++ b/internal/httpclient/client/api/list_rules_parameters.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package api + +// 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" +) + +// NewListRulesParams creates a new ListRulesParams object +// with the default values initialized. +func NewListRulesParams() *ListRulesParams { + var () + return &ListRulesParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewListRulesParamsWithTimeout creates a new ListRulesParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewListRulesParamsWithTimeout(timeout time.Duration) *ListRulesParams { + var () + return &ListRulesParams{ + + timeout: timeout, + } +} + +// NewListRulesParamsWithContext creates a new ListRulesParams object +// with the default values initialized, and the ability to set a context for a request +func NewListRulesParamsWithContext(ctx context.Context) *ListRulesParams { + var () + return &ListRulesParams{ + + Context: ctx, + } +} + +// NewListRulesParamsWithHTTPClient creates a new ListRulesParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewListRulesParamsWithHTTPClient(client *http.Client) *ListRulesParams { + var () + return &ListRulesParams{ + HTTPClient: client, + } +} + +/*ListRulesParams contains all the parameters to send to the API endpoint +for the list rules operation typically these are written to a http.Request +*/ +type ListRulesParams struct { + + /*Limit + The maximum amount of rules returned. + + */ + Limit *int64 + /*Offset + The offset from where to start looking. + + */ + Offset *int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the list rules params +func (o *ListRulesParams) WithTimeout(timeout time.Duration) *ListRulesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list rules params +func (o *ListRulesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list rules params +func (o *ListRulesParams) WithContext(ctx context.Context) *ListRulesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list rules params +func (o *ListRulesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list rules params +func (o *ListRulesParams) WithHTTPClient(client *http.Client) *ListRulesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list rules params +func (o *ListRulesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithLimit adds the limit to the list rules params +func (o *ListRulesParams) WithLimit(limit *int64) *ListRulesParams { + o.SetLimit(limit) + return o +} + +// SetLimit adds the limit to the list rules params +func (o *ListRulesParams) SetLimit(limit *int64) { + o.Limit = limit +} + +// WithOffset adds the offset to the list rules params +func (o *ListRulesParams) WithOffset(offset *int64) *ListRulesParams { + o.SetOffset(offset) + return o +} + +// SetOffset adds the offset to the list rules params +func (o *ListRulesParams) SetOffset(offset *int64) { + o.Offset = offset +} + +// WriteToRequest writes these params to a swagger request +func (o *ListRulesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Limit != nil { + + // query param limit + var qrLimit int64 + if o.Limit != nil { + qrLimit = *o.Limit + } + qLimit := swag.FormatInt64(qrLimit) + if qLimit != "" { + if err := r.SetQueryParam("limit", qLimit); err != nil { + return err + } + } + + } + + if o.Offset != nil { + + // query param offset + var qrOffset int64 + if o.Offset != nil { + qrOffset = *o.Offset + } + qOffset := swag.FormatInt64(qrOffset) + if qOffset != "" { + if err := r.SetQueryParam("offset", qOffset); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/internal/httpclient/client/api/list_rules_responses.go b/internal/httpclient/client/api/list_rules_responses.go new file mode 100644 index 000000000..9c96cd579 --- /dev/null +++ b/internal/httpclient/client/api/list_rules_responses.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package api + +// 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/go-openapi/swag" + + "github.com/ory/oathkeeper/internal/httpclient/models" +) + +// ListRulesReader is a Reader for the ListRules structure. +type ListRulesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListRulesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListRulesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewListRulesInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewListRulesOK creates a ListRulesOK with default headers values +func NewListRulesOK() *ListRulesOK { + return &ListRulesOK{} +} + +/*ListRulesOK handles this case with default header values. + +A list of rules +*/ +type ListRulesOK struct { + Payload []*models.Rule +} + +func (o *ListRulesOK) Error() string { + return fmt.Sprintf("[GET /rules][%d] listRulesOK %+v", 200, o.Payload) +} + +func (o *ListRulesOK) GetPayload() []*models.Rule { + return o.Payload +} + +func (o *ListRulesOK) 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 +} + +// NewListRulesInternalServerError creates a ListRulesInternalServerError with default headers values +func NewListRulesInternalServerError() *ListRulesInternalServerError { + return &ListRulesInternalServerError{} +} + +/*ListRulesInternalServerError handles this case with default header values. + +The standard error format +*/ +type ListRulesInternalServerError struct { + Payload *ListRulesInternalServerErrorBody +} + +func (o *ListRulesInternalServerError) Error() string { + return fmt.Sprintf("[GET /rules][%d] listRulesInternalServerError %+v", 500, o.Payload) +} + +func (o *ListRulesInternalServerError) GetPayload() *ListRulesInternalServerErrorBody { + return o.Payload +} + +func (o *ListRulesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(ListRulesInternalServerErrorBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*ListRulesInternalServerErrorBody list rules internal server error body +swagger:model ListRulesInternalServerErrorBody +*/ +type ListRulesInternalServerErrorBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this list rules internal server error body +func (o *ListRulesInternalServerErrorBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *ListRulesInternalServerErrorBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *ListRulesInternalServerErrorBody) UnmarshalBinary(b []byte) error { + var res ListRulesInternalServerErrorBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/internal/httpclient/client/api/make_generic_decision_parameters.go b/internal/httpclient/client/api/make_generic_decision_parameters.go new file mode 100644 index 000000000..4cc7ccfcb --- /dev/null +++ b/internal/httpclient/client/api/make_generic_decision_parameters.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package api + +// 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" +) + +// NewMakeGenericDecisionParams creates a new MakeGenericDecisionParams object +// with the default values initialized. +func NewMakeGenericDecisionParams() *MakeGenericDecisionParams { + + return &MakeGenericDecisionParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewMakeGenericDecisionParamsWithTimeout creates a new MakeGenericDecisionParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewMakeGenericDecisionParamsWithTimeout(timeout time.Duration) *MakeGenericDecisionParams { + + return &MakeGenericDecisionParams{ + + timeout: timeout, + } +} + +// NewMakeGenericDecisionParamsWithContext creates a new MakeGenericDecisionParams object +// with the default values initialized, and the ability to set a context for a request +func NewMakeGenericDecisionParamsWithContext(ctx context.Context) *MakeGenericDecisionParams { + + return &MakeGenericDecisionParams{ + + Context: ctx, + } +} + +// NewMakeGenericDecisionParamsWithHTTPClient creates a new MakeGenericDecisionParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewMakeGenericDecisionParamsWithHTTPClient(client *http.Client) *MakeGenericDecisionParams { + + return &MakeGenericDecisionParams{ + HTTPClient: client, + } +} + +/*MakeGenericDecisionParams contains all the parameters to send to the API endpoint +for the make generic decision operation typically these are written to a http.Request +*/ +type MakeGenericDecisionParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the make generic decision params +func (o *MakeGenericDecisionParams) WithTimeout(timeout time.Duration) *MakeGenericDecisionParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the make generic decision params +func (o *MakeGenericDecisionParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the make generic decision params +func (o *MakeGenericDecisionParams) WithContext(ctx context.Context) *MakeGenericDecisionParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the make generic decision params +func (o *MakeGenericDecisionParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the make generic decision params +func (o *MakeGenericDecisionParams) WithHTTPClient(client *http.Client) *MakeGenericDecisionParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the make generic decision params +func (o *MakeGenericDecisionParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *MakeGenericDecisionParams) 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/internal/httpclient/client/api/make_generic_decision_responses.go b/internal/httpclient/client/api/make_generic_decision_responses.go new file mode 100644 index 000000000..55d9e2d87 --- /dev/null +++ b/internal/httpclient/client/api/make_generic_decision_responses.go @@ -0,0 +1,400 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package api + +// 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/go-openapi/swag" +) + +// MakeGenericDecisionReader is a Reader for the MakeGenericDecision structure. +type MakeGenericDecisionReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *MakeGenericDecisionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewMakeGenericDecisionOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewMakeGenericDecisionUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewMakeGenericDecisionForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewMakeGenericDecisionNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewMakeGenericDecisionInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewMakeGenericDecisionOK creates a MakeGenericDecisionOK with default headers values +func NewMakeGenericDecisionOK() *MakeGenericDecisionOK { + return &MakeGenericDecisionOK{} +} + +/*MakeGenericDecisionOK handles this case with default header values. + +An empty response +*/ +type MakeGenericDecisionOK struct { +} + +func (o *MakeGenericDecisionOK) Error() string { + return fmt.Sprintf("[GET /decisions/generic][%d] makeGenericDecisionOK ", 200) +} + +func (o *MakeGenericDecisionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewMakeGenericDecisionUnauthorized creates a MakeGenericDecisionUnauthorized with default headers values +func NewMakeGenericDecisionUnauthorized() *MakeGenericDecisionUnauthorized { + return &MakeGenericDecisionUnauthorized{} +} + +/*MakeGenericDecisionUnauthorized handles this case with default header values. + +The standard error format +*/ +type MakeGenericDecisionUnauthorized struct { + Payload *MakeGenericDecisionUnauthorizedBody +} + +func (o *MakeGenericDecisionUnauthorized) Error() string { + return fmt.Sprintf("[GET /decisions/generic][%d] makeGenericDecisionUnauthorized %+v", 401, o.Payload) +} + +func (o *MakeGenericDecisionUnauthorized) GetPayload() *MakeGenericDecisionUnauthorizedBody { + return o.Payload +} + +func (o *MakeGenericDecisionUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(MakeGenericDecisionUnauthorizedBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewMakeGenericDecisionForbidden creates a MakeGenericDecisionForbidden with default headers values +func NewMakeGenericDecisionForbidden() *MakeGenericDecisionForbidden { + return &MakeGenericDecisionForbidden{} +} + +/*MakeGenericDecisionForbidden handles this case with default header values. + +The standard error format +*/ +type MakeGenericDecisionForbidden struct { + Payload *MakeGenericDecisionForbiddenBody +} + +func (o *MakeGenericDecisionForbidden) Error() string { + return fmt.Sprintf("[GET /decisions/generic][%d] makeGenericDecisionForbidden %+v", 403, o.Payload) +} + +func (o *MakeGenericDecisionForbidden) GetPayload() *MakeGenericDecisionForbiddenBody { + return o.Payload +} + +func (o *MakeGenericDecisionForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(MakeGenericDecisionForbiddenBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewMakeGenericDecisionNotFound creates a MakeGenericDecisionNotFound with default headers values +func NewMakeGenericDecisionNotFound() *MakeGenericDecisionNotFound { + return &MakeGenericDecisionNotFound{} +} + +/*MakeGenericDecisionNotFound handles this case with default header values. + +The standard error format +*/ +type MakeGenericDecisionNotFound struct { + Payload *MakeGenericDecisionNotFoundBody +} + +func (o *MakeGenericDecisionNotFound) Error() string { + return fmt.Sprintf("[GET /decisions/generic][%d] makeGenericDecisionNotFound %+v", 404, o.Payload) +} + +func (o *MakeGenericDecisionNotFound) GetPayload() *MakeGenericDecisionNotFoundBody { + return o.Payload +} + +func (o *MakeGenericDecisionNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(MakeGenericDecisionNotFoundBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewMakeGenericDecisionInternalServerError creates a MakeGenericDecisionInternalServerError with default headers values +func NewMakeGenericDecisionInternalServerError() *MakeGenericDecisionInternalServerError { + return &MakeGenericDecisionInternalServerError{} +} + +/*MakeGenericDecisionInternalServerError handles this case with default header values. + +The standard error format +*/ +type MakeGenericDecisionInternalServerError struct { + Payload *MakeGenericDecisionInternalServerErrorBody +} + +func (o *MakeGenericDecisionInternalServerError) Error() string { + return fmt.Sprintf("[GET /decisions/generic][%d] makeGenericDecisionInternalServerError %+v", 500, o.Payload) +} + +func (o *MakeGenericDecisionInternalServerError) GetPayload() *MakeGenericDecisionInternalServerErrorBody { + return o.Payload +} + +func (o *MakeGenericDecisionInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(MakeGenericDecisionInternalServerErrorBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*MakeGenericDecisionForbiddenBody make generic decision forbidden body +swagger:model MakeGenericDecisionForbiddenBody +*/ +type MakeGenericDecisionForbiddenBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this make generic decision forbidden body +func (o *MakeGenericDecisionForbiddenBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *MakeGenericDecisionForbiddenBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *MakeGenericDecisionForbiddenBody) UnmarshalBinary(b []byte) error { + var res MakeGenericDecisionForbiddenBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*MakeGenericDecisionInternalServerErrorBody make generic decision internal server error body +swagger:model MakeGenericDecisionInternalServerErrorBody +*/ +type MakeGenericDecisionInternalServerErrorBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this make generic decision internal server error body +func (o *MakeGenericDecisionInternalServerErrorBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *MakeGenericDecisionInternalServerErrorBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *MakeGenericDecisionInternalServerErrorBody) UnmarshalBinary(b []byte) error { + var res MakeGenericDecisionInternalServerErrorBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*MakeGenericDecisionNotFoundBody make generic decision not found body +swagger:model MakeGenericDecisionNotFoundBody +*/ +type MakeGenericDecisionNotFoundBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this make generic decision not found body +func (o *MakeGenericDecisionNotFoundBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *MakeGenericDecisionNotFoundBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *MakeGenericDecisionNotFoundBody) UnmarshalBinary(b []byte) error { + var res MakeGenericDecisionNotFoundBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*MakeGenericDecisionUnauthorizedBody make generic decision unauthorized body +swagger:model MakeGenericDecisionUnauthorizedBody +*/ +type MakeGenericDecisionUnauthorizedBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this make generic decision unauthorized body +func (o *MakeGenericDecisionUnauthorizedBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *MakeGenericDecisionUnauthorizedBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *MakeGenericDecisionUnauthorizedBody) UnmarshalBinary(b []byte) error { + var res MakeGenericDecisionUnauthorizedBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/internal/httpclient/client/api/make_traefik_decision_parameters.go b/internal/httpclient/client/api/make_traefik_decision_parameters.go new file mode 100644 index 000000000..039eb4ab8 --- /dev/null +++ b/internal/httpclient/client/api/make_traefik_decision_parameters.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package api + +// 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" +) + +// NewMakeTraefikDecisionParams creates a new MakeTraefikDecisionParams object +// with the default values initialized. +func NewMakeTraefikDecisionParams() *MakeTraefikDecisionParams { + + return &MakeTraefikDecisionParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewMakeTraefikDecisionParamsWithTimeout creates a new MakeTraefikDecisionParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewMakeTraefikDecisionParamsWithTimeout(timeout time.Duration) *MakeTraefikDecisionParams { + + return &MakeTraefikDecisionParams{ + + timeout: timeout, + } +} + +// NewMakeTraefikDecisionParamsWithContext creates a new MakeTraefikDecisionParams object +// with the default values initialized, and the ability to set a context for a request +func NewMakeTraefikDecisionParamsWithContext(ctx context.Context) *MakeTraefikDecisionParams { + + return &MakeTraefikDecisionParams{ + + Context: ctx, + } +} + +// NewMakeTraefikDecisionParamsWithHTTPClient creates a new MakeTraefikDecisionParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewMakeTraefikDecisionParamsWithHTTPClient(client *http.Client) *MakeTraefikDecisionParams { + + return &MakeTraefikDecisionParams{ + HTTPClient: client, + } +} + +/*MakeTraefikDecisionParams contains all the parameters to send to the API endpoint +for the make traefik decision operation typically these are written to a http.Request +*/ +type MakeTraefikDecisionParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the make traefik decision params +func (o *MakeTraefikDecisionParams) WithTimeout(timeout time.Duration) *MakeTraefikDecisionParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the make traefik decision params +func (o *MakeTraefikDecisionParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the make traefik decision params +func (o *MakeTraefikDecisionParams) WithContext(ctx context.Context) *MakeTraefikDecisionParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the make traefik decision params +func (o *MakeTraefikDecisionParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the make traefik decision params +func (o *MakeTraefikDecisionParams) WithHTTPClient(client *http.Client) *MakeTraefikDecisionParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the make traefik decision params +func (o *MakeTraefikDecisionParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *MakeTraefikDecisionParams) 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/internal/httpclient/client/api/make_traefik_decision_responses.go b/internal/httpclient/client/api/make_traefik_decision_responses.go new file mode 100644 index 000000000..3114d2347 --- /dev/null +++ b/internal/httpclient/client/api/make_traefik_decision_responses.go @@ -0,0 +1,400 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package api + +// 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/go-openapi/swag" +) + +// MakeTraefikDecisionReader is a Reader for the MakeTraefikDecision structure. +type MakeTraefikDecisionReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *MakeTraefikDecisionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewMakeTraefikDecisionOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewMakeTraefikDecisionUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewMakeTraefikDecisionForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewMakeTraefikDecisionNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewMakeTraefikDecisionInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewMakeTraefikDecisionOK creates a MakeTraefikDecisionOK with default headers values +func NewMakeTraefikDecisionOK() *MakeTraefikDecisionOK { + return &MakeTraefikDecisionOK{} +} + +/*MakeTraefikDecisionOK handles this case with default header values. + +An empty response +*/ +type MakeTraefikDecisionOK struct { +} + +func (o *MakeTraefikDecisionOK) Error() string { + return fmt.Sprintf("[GET /decisions/traefik][%d] makeTraefikDecisionOK ", 200) +} + +func (o *MakeTraefikDecisionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewMakeTraefikDecisionUnauthorized creates a MakeTraefikDecisionUnauthorized with default headers values +func NewMakeTraefikDecisionUnauthorized() *MakeTraefikDecisionUnauthorized { + return &MakeTraefikDecisionUnauthorized{} +} + +/*MakeTraefikDecisionUnauthorized handles this case with default header values. + +The standard error format +*/ +type MakeTraefikDecisionUnauthorized struct { + Payload *MakeTraefikDecisionUnauthorizedBody +} + +func (o *MakeTraefikDecisionUnauthorized) Error() string { + return fmt.Sprintf("[GET /decisions/traefik][%d] makeTraefikDecisionUnauthorized %+v", 401, o.Payload) +} + +func (o *MakeTraefikDecisionUnauthorized) GetPayload() *MakeTraefikDecisionUnauthorizedBody { + return o.Payload +} + +func (o *MakeTraefikDecisionUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(MakeTraefikDecisionUnauthorizedBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewMakeTraefikDecisionForbidden creates a MakeTraefikDecisionForbidden with default headers values +func NewMakeTraefikDecisionForbidden() *MakeTraefikDecisionForbidden { + return &MakeTraefikDecisionForbidden{} +} + +/*MakeTraefikDecisionForbidden handles this case with default header values. + +The standard error format +*/ +type MakeTraefikDecisionForbidden struct { + Payload *MakeTraefikDecisionForbiddenBody +} + +func (o *MakeTraefikDecisionForbidden) Error() string { + return fmt.Sprintf("[GET /decisions/traefik][%d] makeTraefikDecisionForbidden %+v", 403, o.Payload) +} + +func (o *MakeTraefikDecisionForbidden) GetPayload() *MakeTraefikDecisionForbiddenBody { + return o.Payload +} + +func (o *MakeTraefikDecisionForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(MakeTraefikDecisionForbiddenBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewMakeTraefikDecisionNotFound creates a MakeTraefikDecisionNotFound with default headers values +func NewMakeTraefikDecisionNotFound() *MakeTraefikDecisionNotFound { + return &MakeTraefikDecisionNotFound{} +} + +/*MakeTraefikDecisionNotFound handles this case with default header values. + +The standard error format +*/ +type MakeTraefikDecisionNotFound struct { + Payload *MakeTraefikDecisionNotFoundBody +} + +func (o *MakeTraefikDecisionNotFound) Error() string { + return fmt.Sprintf("[GET /decisions/traefik][%d] makeTraefikDecisionNotFound %+v", 404, o.Payload) +} + +func (o *MakeTraefikDecisionNotFound) GetPayload() *MakeTraefikDecisionNotFoundBody { + return o.Payload +} + +func (o *MakeTraefikDecisionNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(MakeTraefikDecisionNotFoundBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewMakeTraefikDecisionInternalServerError creates a MakeTraefikDecisionInternalServerError with default headers values +func NewMakeTraefikDecisionInternalServerError() *MakeTraefikDecisionInternalServerError { + return &MakeTraefikDecisionInternalServerError{} +} + +/*MakeTraefikDecisionInternalServerError handles this case with default header values. + +The standard error format +*/ +type MakeTraefikDecisionInternalServerError struct { + Payload *MakeTraefikDecisionInternalServerErrorBody +} + +func (o *MakeTraefikDecisionInternalServerError) Error() string { + return fmt.Sprintf("[GET /decisions/traefik][%d] makeTraefikDecisionInternalServerError %+v", 500, o.Payload) +} + +func (o *MakeTraefikDecisionInternalServerError) GetPayload() *MakeTraefikDecisionInternalServerErrorBody { + return o.Payload +} + +func (o *MakeTraefikDecisionInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(MakeTraefikDecisionInternalServerErrorBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*MakeTraefikDecisionForbiddenBody make traefik decision forbidden body +swagger:model MakeTraefikDecisionForbiddenBody +*/ +type MakeTraefikDecisionForbiddenBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this make traefik decision forbidden body +func (o *MakeTraefikDecisionForbiddenBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *MakeTraefikDecisionForbiddenBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *MakeTraefikDecisionForbiddenBody) UnmarshalBinary(b []byte) error { + var res MakeTraefikDecisionForbiddenBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*MakeTraefikDecisionInternalServerErrorBody make traefik decision internal server error body +swagger:model MakeTraefikDecisionInternalServerErrorBody +*/ +type MakeTraefikDecisionInternalServerErrorBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this make traefik decision internal server error body +func (o *MakeTraefikDecisionInternalServerErrorBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *MakeTraefikDecisionInternalServerErrorBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *MakeTraefikDecisionInternalServerErrorBody) UnmarshalBinary(b []byte) error { + var res MakeTraefikDecisionInternalServerErrorBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*MakeTraefikDecisionNotFoundBody make traefik decision not found body +swagger:model MakeTraefikDecisionNotFoundBody +*/ +type MakeTraefikDecisionNotFoundBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this make traefik decision not found body +func (o *MakeTraefikDecisionNotFoundBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *MakeTraefikDecisionNotFoundBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *MakeTraefikDecisionNotFoundBody) UnmarshalBinary(b []byte) error { + var res MakeTraefikDecisionNotFoundBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*MakeTraefikDecisionUnauthorizedBody make traefik decision unauthorized body +swagger:model MakeTraefikDecisionUnauthorizedBody +*/ +type MakeTraefikDecisionUnauthorizedBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this make traefik decision unauthorized body +func (o *MakeTraefikDecisionUnauthorizedBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *MakeTraefikDecisionUnauthorizedBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *MakeTraefikDecisionUnauthorizedBody) UnmarshalBinary(b []byte) error { + var res MakeTraefikDecisionUnauthorizedBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/internal/httpclient/client/health/health_client.go b/internal/httpclient/client/health/health_client.go new file mode 100644 index 000000000..2b0fc4972 --- /dev/null +++ b/internal/httpclient/client/health/health_client.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// 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" + "github.com/go-openapi/strfmt" +) + +// New creates a new health API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for health API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientService is the interface for Client methods +type ClientService interface { + IsInstanceAlive(params *IsInstanceAliveParams) (*IsInstanceAliveOK, error) + + IsInstanceReady(params *IsInstanceReadyParams) (*IsInstanceReadyOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + IsInstanceAlive checks alive status + + This endpoint returns a 200 status code when the HTTP server is up running. +This status does currently not include checks whether the database connection is working. + +If the service supports TLS Edge Termination, this endpoint does not require the +`X-Forwarded-Proto` header to be set. + +Be aware that if you are running multiple nodes of this service, the health status will never +refer to the cluster state, only to a single instance. +*/ +func (a *Client) IsInstanceAlive(params *IsInstanceAliveParams) (*IsInstanceAliveOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewIsInstanceAliveParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "isInstanceAlive", + Method: "GET", + PathPattern: "/health/alive", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &IsInstanceAliveReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*IsInstanceAliveOK) + 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 isInstanceAlive: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + IsInstanceReady checks readiness status + + This endpoint returns a 200 status code when the HTTP server is up running and the environment dependencies (e.g. +the database) are responsive as well. + +If the service supports TLS Edge Termination, this endpoint does not require the +`X-Forwarded-Proto` header to be set. + +Be aware that if you are running multiple nodes of this service, the health status will never +refer to the cluster state, only to a single instance. +*/ +func (a *Client) IsInstanceReady(params *IsInstanceReadyParams) (*IsInstanceReadyOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewIsInstanceReadyParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "isInstanceReady", + Method: "GET", + PathPattern: "/health/ready", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &IsInstanceReadyReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*IsInstanceReadyOK) + 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 isInstanceReady: 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 +} diff --git a/internal/httpclient/client/health/is_instance_alive_parameters.go b/internal/httpclient/client/health/is_instance_alive_parameters.go new file mode 100644 index 000000000..7f882b77e --- /dev/null +++ b/internal/httpclient/client/health/is_instance_alive_parameters.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// 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" +) + +// NewIsInstanceAliveParams creates a new IsInstanceAliveParams object +// with the default values initialized. +func NewIsInstanceAliveParams() *IsInstanceAliveParams { + + return &IsInstanceAliveParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewIsInstanceAliveParamsWithTimeout creates a new IsInstanceAliveParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewIsInstanceAliveParamsWithTimeout(timeout time.Duration) *IsInstanceAliveParams { + + return &IsInstanceAliveParams{ + + timeout: timeout, + } +} + +// NewIsInstanceAliveParamsWithContext creates a new IsInstanceAliveParams object +// with the default values initialized, and the ability to set a context for a request +func NewIsInstanceAliveParamsWithContext(ctx context.Context) *IsInstanceAliveParams { + + return &IsInstanceAliveParams{ + + Context: ctx, + } +} + +// NewIsInstanceAliveParamsWithHTTPClient creates a new IsInstanceAliveParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewIsInstanceAliveParamsWithHTTPClient(client *http.Client) *IsInstanceAliveParams { + + return &IsInstanceAliveParams{ + HTTPClient: client, + } +} + +/*IsInstanceAliveParams contains all the parameters to send to the API endpoint +for the is instance alive operation typically these are written to a http.Request +*/ +type IsInstanceAliveParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the is instance alive params +func (o *IsInstanceAliveParams) WithTimeout(timeout time.Duration) *IsInstanceAliveParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the is instance alive params +func (o *IsInstanceAliveParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the is instance alive params +func (o *IsInstanceAliveParams) WithContext(ctx context.Context) *IsInstanceAliveParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the is instance alive params +func (o *IsInstanceAliveParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the is instance alive params +func (o *IsInstanceAliveParams) WithHTTPClient(client *http.Client) *IsInstanceAliveParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the is instance alive params +func (o *IsInstanceAliveParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *IsInstanceAliveParams) 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/internal/httpclient/client/health/is_instance_alive_responses.go b/internal/httpclient/client/health/is_instance_alive_responses.go new file mode 100644 index 000000000..579ef128d --- /dev/null +++ b/internal/httpclient/client/health/is_instance_alive_responses.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// 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/go-openapi/swag" + + "github.com/ory/oathkeeper/internal/httpclient/models" +) + +// IsInstanceAliveReader is a Reader for the IsInstanceAlive structure. +type IsInstanceAliveReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *IsInstanceAliveReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewIsInstanceAliveOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewIsInstanceAliveInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewIsInstanceAliveOK creates a IsInstanceAliveOK with default headers values +func NewIsInstanceAliveOK() *IsInstanceAliveOK { + return &IsInstanceAliveOK{} +} + +/*IsInstanceAliveOK handles this case with default header values. + +healthStatus +*/ +type IsInstanceAliveOK struct { + Payload *models.HealthStatus +} + +func (o *IsInstanceAliveOK) Error() string { + return fmt.Sprintf("[GET /health/alive][%d] isInstanceAliveOK %+v", 200, o.Payload) +} + +func (o *IsInstanceAliveOK) GetPayload() *models.HealthStatus { + return o.Payload +} + +func (o *IsInstanceAliveOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.HealthStatus) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewIsInstanceAliveInternalServerError creates a IsInstanceAliveInternalServerError with default headers values +func NewIsInstanceAliveInternalServerError() *IsInstanceAliveInternalServerError { + return &IsInstanceAliveInternalServerError{} +} + +/*IsInstanceAliveInternalServerError handles this case with default header values. + +The standard error format +*/ +type IsInstanceAliveInternalServerError struct { + Payload *IsInstanceAliveInternalServerErrorBody +} + +func (o *IsInstanceAliveInternalServerError) Error() string { + return fmt.Sprintf("[GET /health/alive][%d] isInstanceAliveInternalServerError %+v", 500, o.Payload) +} + +func (o *IsInstanceAliveInternalServerError) GetPayload() *IsInstanceAliveInternalServerErrorBody { + return o.Payload +} + +func (o *IsInstanceAliveInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(IsInstanceAliveInternalServerErrorBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*IsInstanceAliveInternalServerErrorBody is instance alive internal server error body +swagger:model IsInstanceAliveInternalServerErrorBody +*/ +type IsInstanceAliveInternalServerErrorBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // details + Details []interface{} `json:"details"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // request + Request string `json:"request,omitempty"` + + // status + Status string `json:"status,omitempty"` +} + +// Validate validates this is instance alive internal server error body +func (o *IsInstanceAliveInternalServerErrorBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *IsInstanceAliveInternalServerErrorBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *IsInstanceAliveInternalServerErrorBody) UnmarshalBinary(b []byte) error { + var res IsInstanceAliveInternalServerErrorBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/internal/httpclient/client/health/is_instance_ready_parameters.go b/internal/httpclient/client/health/is_instance_ready_parameters.go new file mode 100644 index 000000000..f03a934a8 --- /dev/null +++ b/internal/httpclient/client/health/is_instance_ready_parameters.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// 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" +) + +// NewIsInstanceReadyParams creates a new IsInstanceReadyParams object +// with the default values initialized. +func NewIsInstanceReadyParams() *IsInstanceReadyParams { + + return &IsInstanceReadyParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewIsInstanceReadyParamsWithTimeout creates a new IsInstanceReadyParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewIsInstanceReadyParamsWithTimeout(timeout time.Duration) *IsInstanceReadyParams { + + return &IsInstanceReadyParams{ + + timeout: timeout, + } +} + +// NewIsInstanceReadyParamsWithContext creates a new IsInstanceReadyParams object +// with the default values initialized, and the ability to set a context for a request +func NewIsInstanceReadyParamsWithContext(ctx context.Context) *IsInstanceReadyParams { + + return &IsInstanceReadyParams{ + + Context: ctx, + } +} + +// NewIsInstanceReadyParamsWithHTTPClient creates a new IsInstanceReadyParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewIsInstanceReadyParamsWithHTTPClient(client *http.Client) *IsInstanceReadyParams { + + return &IsInstanceReadyParams{ + HTTPClient: client, + } +} + +/*IsInstanceReadyParams contains all the parameters to send to the API endpoint +for the is instance ready operation typically these are written to a http.Request +*/ +type IsInstanceReadyParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the is instance ready params +func (o *IsInstanceReadyParams) WithTimeout(timeout time.Duration) *IsInstanceReadyParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the is instance ready params +func (o *IsInstanceReadyParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the is instance ready params +func (o *IsInstanceReadyParams) WithContext(ctx context.Context) *IsInstanceReadyParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the is instance ready params +func (o *IsInstanceReadyParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the is instance ready params +func (o *IsInstanceReadyParams) WithHTTPClient(client *http.Client) *IsInstanceReadyParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the is instance ready params +func (o *IsInstanceReadyParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *IsInstanceReadyParams) 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/internal/httpclient/client/health/is_instance_ready_responses.go b/internal/httpclient/client/health/is_instance_ready_responses.go new file mode 100644 index 000000000..bc105b705 --- /dev/null +++ b/internal/httpclient/client/health/is_instance_ready_responses.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// 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/ory/oathkeeper/internal/httpclient/models" +) + +// IsInstanceReadyReader is a Reader for the IsInstanceReady structure. +type IsInstanceReadyReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *IsInstanceReadyReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewIsInstanceReadyOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 503: + result := NewIsInstanceReadyServiceUnavailable() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewIsInstanceReadyOK creates a IsInstanceReadyOK with default headers values +func NewIsInstanceReadyOK() *IsInstanceReadyOK { + return &IsInstanceReadyOK{} +} + +/*IsInstanceReadyOK handles this case with default header values. + +healthStatus +*/ +type IsInstanceReadyOK struct { + Payload *models.HealthStatus +} + +func (o *IsInstanceReadyOK) Error() string { + return fmt.Sprintf("[GET /health/ready][%d] isInstanceReadyOK %+v", 200, o.Payload) +} + +func (o *IsInstanceReadyOK) GetPayload() *models.HealthStatus { + return o.Payload +} + +func (o *IsInstanceReadyOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.HealthStatus) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewIsInstanceReadyServiceUnavailable creates a IsInstanceReadyServiceUnavailable with default headers values +func NewIsInstanceReadyServiceUnavailable() *IsInstanceReadyServiceUnavailable { + return &IsInstanceReadyServiceUnavailable{} +} + +/*IsInstanceReadyServiceUnavailable handles this case with default header values. + +healthNotReadyStatus +*/ +type IsInstanceReadyServiceUnavailable struct { + Payload *models.HealthNotReadyStatus +} + +func (o *IsInstanceReadyServiceUnavailable) Error() string { + return fmt.Sprintf("[GET /health/ready][%d] isInstanceReadyServiceUnavailable %+v", 503, o.Payload) +} + +func (o *IsInstanceReadyServiceUnavailable) GetPayload() *models.HealthNotReadyStatus { + return o.Payload +} + +func (o *IsInstanceReadyServiceUnavailable) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.HealthNotReadyStatus) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/internal/httpclient/client/ory_oathkeeper_client.go b/internal/httpclient/client/ory_oathkeeper_client.go new file mode 100644 index 000000000..c43e3f6ab --- /dev/null +++ b/internal/httpclient/client/ory_oathkeeper_client.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package client + +// 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" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + apiops "github.com/ory/oathkeeper/internal/httpclient/client/api" + "github.com/ory/oathkeeper/internal/httpclient/client/health" + "github.com/ory/oathkeeper/internal/httpclient/client/version" +) + +// Default ory oathkeeper HTTP client. +var Default = NewHTTPClient(nil) + +const ( + // DefaultHost is the default Host + // found in Meta (info) section of spec file + DefaultHost string = "localhost" + // DefaultBasePath is the default BasePath + // found in Meta (info) section of spec file + DefaultBasePath string = "/" +) + +// DefaultSchemes are the default schemes found in Meta (info) section of spec file +var DefaultSchemes = []string{"http", "https"} + +// NewHTTPClient creates a new ory oathkeeper HTTP client. +func NewHTTPClient(formats strfmt.Registry) *OryOathkeeper { + return NewHTTPClientWithConfig(formats, nil) +} + +// NewHTTPClientWithConfig creates a new ory oathkeeper HTTP client, +// using a customizable transport config. +func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *OryOathkeeper { + // ensure nullable parameters have default + if cfg == nil { + cfg = DefaultTransportConfig() + } + + // create transport and client + transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) + return New(transport, formats) +} + +// New creates a new ory oathkeeper client +func New(transport runtime.ClientTransport, formats strfmt.Registry) *OryOathkeeper { + // ensure nullable parameters have default + if formats == nil { + formats = strfmt.Default + } + + cli := new(OryOathkeeper) + cli.Transport = transport + cli.API = apiops.New(transport, formats) + cli.Health = health.New(transport, formats) + cli.Version = version.New(transport, formats) + return cli +} + +// DefaultTransportConfig creates a TransportConfig with the +// default settings taken from the meta section of the spec file. +func DefaultTransportConfig() *TransportConfig { + return &TransportConfig{ + Host: DefaultHost, + BasePath: DefaultBasePath, + Schemes: DefaultSchemes, + } +} + +// TransportConfig contains the transport related info, +// found in the meta section of the spec file. +type TransportConfig struct { + Host string + BasePath string + Schemes []string +} + +// WithHost overrides the default host, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithHost(host string) *TransportConfig { + cfg.Host = host + return cfg +} + +// WithBasePath overrides the default basePath, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { + cfg.BasePath = basePath + return cfg +} + +// WithSchemes overrides the default schemes, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { + cfg.Schemes = schemes + return cfg +} + +// OryOathkeeper is a client for ory oathkeeper +type OryOathkeeper struct { + API apiops.ClientService + + Health health.ClientService + + Version version.ClientService + + Transport runtime.ClientTransport +} + +// SetTransport changes the transport on the client and all its subresources +func (c *OryOathkeeper) SetTransport(transport runtime.ClientTransport) { + c.Transport = transport + c.API.SetTransport(transport) + c.Health.SetTransport(transport) + c.Version.SetTransport(transport) +} diff --git a/internal/httpclient/client/version/get_version_parameters.go b/internal/httpclient/client/version/get_version_parameters.go new file mode 100644 index 000000000..29bf00d13 --- /dev/null +++ b/internal/httpclient/client/version/get_version_parameters.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package version + +// 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" +) + +// NewGetVersionParams creates a new GetVersionParams object +// with the default values initialized. +func NewGetVersionParams() *GetVersionParams { + + return &GetVersionParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetVersionParamsWithTimeout creates a new GetVersionParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetVersionParamsWithTimeout(timeout time.Duration) *GetVersionParams { + + return &GetVersionParams{ + + timeout: timeout, + } +} + +// NewGetVersionParamsWithContext creates a new GetVersionParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetVersionParamsWithContext(ctx context.Context) *GetVersionParams { + + return &GetVersionParams{ + + Context: ctx, + } +} + +// NewGetVersionParamsWithHTTPClient creates a new GetVersionParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetVersionParamsWithHTTPClient(client *http.Client) *GetVersionParams { + + return &GetVersionParams{ + HTTPClient: client, + } +} + +/*GetVersionParams contains all the parameters to send to the API endpoint +for the get version operation typically these are written to a http.Request +*/ +type GetVersionParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get version params +func (o *GetVersionParams) WithTimeout(timeout time.Duration) *GetVersionParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get version params +func (o *GetVersionParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get version params +func (o *GetVersionParams) WithContext(ctx context.Context) *GetVersionParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get version params +func (o *GetVersionParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get version params +func (o *GetVersionParams) WithHTTPClient(client *http.Client) *GetVersionParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get version params +func (o *GetVersionParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *GetVersionParams) 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/internal/httpclient/client/version/get_version_responses.go b/internal/httpclient/client/version/get_version_responses.go new file mode 100644 index 000000000..493a8d8be --- /dev/null +++ b/internal/httpclient/client/version/get_version_responses.go @@ -0,0 +1,69 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package version + +// 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/ory/oathkeeper/internal/httpclient/models" +) + +// GetVersionReader is a Reader for the GetVersion structure. +type GetVersionReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetVersionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetVersionOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewGetVersionOK creates a GetVersionOK with default headers values +func NewGetVersionOK() *GetVersionOK { + return &GetVersionOK{} +} + +/*GetVersionOK handles this case with default header values. + +version +*/ +type GetVersionOK struct { + Payload *models.Version +} + +func (o *GetVersionOK) Error() string { + return fmt.Sprintf("[GET /version][%d] getVersionOK %+v", 200, o.Payload) +} + +func (o *GetVersionOK) GetPayload() *models.Version { + return o.Payload +} + +func (o *GetVersionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Version) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/internal/httpclient/client/version/version_client.go b/internal/httpclient/client/version/version_client.go new file mode 100644 index 000000000..26e31d284 --- /dev/null +++ b/internal/httpclient/client/version/version_client.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package version + +// 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" + "github.com/go-openapi/strfmt" +) + +// New creates a new version API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for version API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientService is the interface for Client methods +type ClientService interface { + GetVersion(params *GetVersionParams) (*GetVersionOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + GetVersion gets service version + + This endpoint returns the service version typically notated using semantic versioning. + +If the service supports TLS Edge Termination, this endpoint does not require the +`X-Forwarded-Proto` header to be set. + +Be aware that if you are running multiple nodes of this service, the health status will never +refer to the cluster state, only to a single instance. +*/ +func (a *Client) GetVersion(params *GetVersionParams) (*GetVersionOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetVersionParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getVersion", + Method: "GET", + PathPattern: "/version", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetVersionReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*GetVersionOK) + 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 getVersion: 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 +} diff --git a/internal/httpclient/models/health_not_ready_status.go b/internal/httpclient/models/health_not_ready_status.go new file mode 100644 index 000000000..64626783e --- /dev/null +++ b/internal/httpclient/models/health_not_ready_status.go @@ -0,0 +1,43 @@ +// 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" +) + +// HealthNotReadyStatus health not ready status +// +// swagger:model healthNotReadyStatus +type HealthNotReadyStatus struct { + + // Errors contains a list of errors that caused the not ready status. + Errors map[string]string `json:"errors,omitempty"` +} + +// Validate validates this health not ready status +func (m *HealthNotReadyStatus) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *HealthNotReadyStatus) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *HealthNotReadyStatus) UnmarshalBinary(b []byte) error { + var res HealthNotReadyStatus + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/internal/httpclient/models/health_status.go b/internal/httpclient/models/health_status.go new file mode 100644 index 000000000..60ba32416 --- /dev/null +++ b/internal/httpclient/models/health_status.go @@ -0,0 +1,43 @@ +// 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" +) + +// HealthStatus health status +// +// swagger:model healthStatus +type HealthStatus struct { + + // Status always contains "ok". + Status string `json:"status,omitempty"` +} + +// Validate validates this health status +func (m *HealthStatus) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *HealthStatus) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *HealthStatus) UnmarshalBinary(b []byte) error { + var res HealthStatus + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/internal/httpclient/models/json_web_key.go b/internal/httpclient/models/json_web_key.go new file mode 100644 index 000000000..6425597b3 --- /dev/null +++ b/internal/httpclient/models/json_web_key.go @@ -0,0 +1,116 @@ +// 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" +) + +// JSONWebKey json web key +// +// swagger:model jsonWebKey +type JSONWebKey struct { + + // The "alg" (algorithm) parameter identifies the algorithm intended for + // use with the key. The values used should either be registered in the + // IANA "JSON Web Signature and Encryption Algorithms" registry + // established by [JWA] or be a value that contains a Collision- + // Resistant Name. + Alg string `json:"alg,omitempty"` + + // crv + Crv string `json:"crv,omitempty"` + + // d + D string `json:"d,omitempty"` + + // dp + Dp string `json:"dp,omitempty"` + + // dq + Dq string `json:"dq,omitempty"` + + // e + E string `json:"e,omitempty"` + + // k + K string `json:"k,omitempty"` + + // The "kid" (key ID) parameter is used to match a specific key. This + // is used, for instance, to choose among a set of keys within a JWK Set + // during key rollover. The structure of the "kid" value is + // unspecified. When "kid" values are used within a JWK Set, different + // keys within the JWK Set SHOULD use distinct "kid" values. (One + // example in which different keys might use the same "kid" value is if + // they have different "kty" (key type) values but are considered to be + // equivalent alternatives by the application using them.) The "kid" + // value is a case-sensitive string. + Kid string `json:"kid,omitempty"` + + // The "kty" (key type) parameter identifies the cryptographic algorithm + // family used with the key, such as "RSA" or "EC". "kty" values should + // either be registered in the IANA "JSON Web Key Types" registry + // established by [JWA] or be a value that contains a Collision- + // Resistant Name. The "kty" value is a case-sensitive string. + Kty string `json:"kty,omitempty"` + + // n + N string `json:"n,omitempty"` + + // p + P string `json:"p,omitempty"` + + // q + Q string `json:"q,omitempty"` + + // qi + Qi string `json:"qi,omitempty"` + + // The "use" (public key use) parameter identifies the intended use of + // the public key. The "use" parameter is employed to indicate whether + // a public key is used for encrypting data or verifying the signature + // on data. Values are commonly "sig" (signature) or "enc" (encryption). + Use string `json:"use,omitempty"` + + // x + X string `json:"x,omitempty"` + + // The "x5c" (X.509 certificate chain) parameter contains a chain of one + // or more PKIX certificates [RFC5280]. The certificate chain is + // represented as a JSON array of certificate value strings. Each + // string in the array is a base64-encoded (Section 4 of [RFC4648] -- + // not base64url-encoded) DER [ITU.X690.1994] PKIX certificate value. + // The PKIX certificate containing the key value MUST be the first + // certificate. + X5c []string `json:"x5c"` + + // y + Y string `json:"y,omitempty"` +} + +// Validate validates this json web key +func (m *JSONWebKey) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *JSONWebKey) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *JSONWebKey) UnmarshalBinary(b []byte) error { + var res JSONWebKey + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/internal/httpclient/models/json_web_key_set.go b/internal/httpclient/models/json_web_key_set.go new file mode 100644 index 000000000..66eb83fab --- /dev/null +++ b/internal/httpclient/models/json_web_key_set.go @@ -0,0 +1,84 @@ +// 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 ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// JSONWebKeySet json web key set +// +// swagger:model jsonWebKeySet +type JSONWebKeySet struct { + + // The value of the "keys" parameter is an array of JWK values. By + // default, the order of the JWK values within the array does not imply + // an order of preference among them, although applications of JWK Sets + // can choose to assign a meaning to the order for their purposes, if + // desired. + Keys []*JSONWebKey `json:"keys"` +} + +// Validate validates this json web key set +func (m *JSONWebKeySet) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateKeys(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *JSONWebKeySet) validateKeys(formats strfmt.Registry) error { + + if swag.IsZero(m.Keys) { // not required + return nil + } + + for i := 0; i < len(m.Keys); i++ { + if swag.IsZero(m.Keys[i]) { // not required + continue + } + + if m.Keys[i] != nil { + if err := m.Keys[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keys" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *JSONWebKeySet) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *JSONWebKeySet) UnmarshalBinary(b []byte) error { + var res JSONWebKeySet + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/internal/httpclient/models/rule.go b/internal/httpclient/models/rule.go new file mode 100644 index 000000000..275ded0f5 --- /dev/null +++ b/internal/httpclient/models/rule.go @@ -0,0 +1,202 @@ +// 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 ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Rule swaggerRule is a single rule that will get checked on every HTTP request. +// +// swagger:model rule +type Rule struct { + + // Authenticators is a list of authentication handlers that will try and authenticate the provided credentials. + // Authenticators are checked iteratively from index 0 to n and if the first authenticator to return a positive + // result will be the one used. + // + // If you want the rule to first check a specific authenticator before "falling back" to others, have that authenticator + // as the first item in the array. + Authenticators []*RuleHandler `json:"authenticators"` + + // authorizer + Authorizer *RuleHandler `json:"authorizer,omitempty"` + + // Description is a human readable description of this rule. + Description string `json:"description,omitempty"` + + // ID is the unique id of the rule. It can be at most 190 characters long, but the layout of the ID is up to you. + // You will need this ID later on to update or delete the rule. + ID string `json:"id,omitempty"` + + // match + Match *RuleMatch `json:"match,omitempty"` + + // Mutators is a list of mutation handlers that transform the HTTP request. A common use case is generating a new set + // of credentials (e.g. JWT) which then will be forwarded to the upstream server. + // + // Mutations are performed iteratively from index 0 to n and should all succeed in order for the HTTP request to be forwarded. + Mutators []*RuleHandler `json:"mutators"` + + // upstream + Upstream *Upstream `json:"upstream,omitempty"` +} + +// Validate validates this rule +func (m *Rule) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthenticators(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAuthorizer(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatch(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMutators(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpstream(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Rule) validateAuthenticators(formats strfmt.Registry) error { + + if swag.IsZero(m.Authenticators) { // not required + return nil + } + + for i := 0; i < len(m.Authenticators); i++ { + if swag.IsZero(m.Authenticators[i]) { // not required + continue + } + + if m.Authenticators[i] != nil { + if err := m.Authenticators[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authenticators" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Rule) validateAuthorizer(formats strfmt.Registry) error { + + if swag.IsZero(m.Authorizer) { // not required + return nil + } + + if m.Authorizer != nil { + if err := m.Authorizer.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authorizer") + } + return err + } + } + + return nil +} + +func (m *Rule) validateMatch(formats strfmt.Registry) error { + + if swag.IsZero(m.Match) { // not required + return nil + } + + if m.Match != nil { + if err := m.Match.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("match") + } + return err + } + } + + return nil +} + +func (m *Rule) validateMutators(formats strfmt.Registry) error { + + if swag.IsZero(m.Mutators) { // not required + return nil + } + + for i := 0; i < len(m.Mutators); i++ { + if swag.IsZero(m.Mutators[i]) { // not required + continue + } + + if m.Mutators[i] != nil { + if err := m.Mutators[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("mutators" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Rule) validateUpstream(formats strfmt.Registry) error { + + if swag.IsZero(m.Upstream) { // not required + return nil + } + + if m.Upstream != nil { + if err := m.Upstream.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("upstream") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Rule) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Rule) UnmarshalBinary(b []byte) error { + var res Rule + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/internal/httpclient/models/rule_handler.go b/internal/httpclient/models/rule_handler.go new file mode 100644 index 000000000..e3bb22474 --- /dev/null +++ b/internal/httpclient/models/rule_handler.go @@ -0,0 +1,48 @@ +// 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" +) + +// RuleHandler rule handler +// +// swagger:model ruleHandler +type RuleHandler struct { + + // Config contains the configuration for the handler. Please read the user + // guide for a complete list of each handler's available settings. + Config interface{} `json:"config,omitempty"` + + // Handler identifies the implementation which will be used to handle this specific request. Please read the user + // guide for a complete list of available handlers. + Handler string `json:"handler,omitempty"` +} + +// Validate validates this rule handler +func (m *RuleHandler) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RuleHandler) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RuleHandler) UnmarshalBinary(b []byte) error { + var res RuleHandler + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/internal/httpclient/models/rule_match.go b/internal/httpclient/models/rule_match.go new file mode 100644 index 000000000..5c5b6eef2 --- /dev/null +++ b/internal/httpclient/models/rule_match.go @@ -0,0 +1,56 @@ +// 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" +) + +// RuleMatch rule match +// +// swagger:model ruleMatch +type RuleMatch struct { + + // An array of HTTP methods (e.g. GET, POST, PUT, DELETE, ...). When ORY Oathkeeper searches for rules + // to decide what to do with an incoming request to the proxy server, it compares the HTTP method of the incoming + // request with the HTTP methods of each rules. If a match is found, the rule is considered a partial match. + // If the matchesUrl field is satisfied as well, the rule is considered a full match. + Methods []string `json:"methods"` + + // This field represents the URL pattern this rule matches. When ORY Oathkeeper searches for rules + // to decide what to do with an incoming request to the proxy server, it compares the full request URL + // (e.g. https://mydomain.com/api/resource) without query parameters of the incoming + // request with this field. If a match is found, the rule is considered a partial match. + // If the matchesMethods field is satisfied as well, the rule is considered a full match. + // + // You can use regular expressions in this field to match more than one url. Regular expressions are encapsulated in + // brackets < and >. The following example matches all paths of the domain `mydomain.com`: `https://mydomain.com/<.*>`. + URL string `json:"url,omitempty"` +} + +// Validate validates this rule match +func (m *RuleMatch) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RuleMatch) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RuleMatch) UnmarshalBinary(b []byte) error { + var res RuleMatch + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/internal/httpclient/models/upstream.go b/internal/httpclient/models/upstream.go new file mode 100644 index 000000000..e1bdc5d23 --- /dev/null +++ b/internal/httpclient/models/upstream.go @@ -0,0 +1,50 @@ +// 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" +) + +// Upstream upstream +// +// swagger:model Upstream +type Upstream struct { + + // PreserveHost, if false (the default), tells ORY Oathkeeper to set the upstream request's Host header to the + // hostname of the API's upstream's URL. Setting this flag to true instructs ORY Oathkeeper not to do so. + PreserveHost bool `json:"preserve_host,omitempty"` + + // StripPath if set, replaces the provided path prefix when forwarding the requested URL to the upstream URL. + StripPath string `json:"strip_path,omitempty"` + + // URL is the URL the request will be proxied to. + URL string `json:"url,omitempty"` +} + +// Validate validates this upstream +func (m *Upstream) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Upstream) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Upstream) UnmarshalBinary(b []byte) error { + var res Upstream + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/internal/httpclient/models/version.go b/internal/httpclient/models/version.go new file mode 100644 index 000000000..8e687bcb2 --- /dev/null +++ b/internal/httpclient/models/version.go @@ -0,0 +1,43 @@ +// 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" +) + +// Version version +// +// swagger:model version +type Version struct { + + // Version is the service's version. + Version string `json:"version,omitempty"` +} + +// Validate validates this version +func (m *Version) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Version) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Version) UnmarshalBinary(b []byte) error { + var res Version + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +}