From 961b258ff7079070ab41349e1155c5f3f0d9802a Mon Sep 17 00:00:00 2001 From: niedbalski Date: Tue, 5 Sep 2023 10:38:58 +0000 Subject: [PATCH] [create-pull-request] automated change --- client/client.go | 24 ++++++++++++++++++++++-- spec/open-api.yml | 13 +++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/client/client.go b/client/client.go index 209e9ac..b630e41 100644 --- a/client/client.go +++ b/client/client.go @@ -9,6 +9,7 @@ import ( "io" "net/http" "net/url" + "os" "github.com/peterhellberg/link" "gopkg.in/yaml.v2" @@ -18,8 +19,11 @@ import ( const ( // DefaultBaseURL of the API. - DefaultBaseURL = "https://cloud-api.calyptia.com" - uintBase = 10 + DefaultBaseURL = "https://cloud-api.calyptia.com" + uintBase = 10 + CalyptiaEnvAPIURL = "CALYPTIA_API_URL" + //nolint: gosec // no credential leaks just a variable. + CalyptiaEnvAPIToken = "CALYPTIA_API_TOKEN" ) // Client is the client over the REST HTTP API of Calyptia Cloud. @@ -41,6 +45,22 @@ func New() *Client { } } +// NewFromEnv creates a new client using default environment variables. +func NewFromEnv() *Client { + c := New() + + // Update the BaseURL if environment variable is set + if apiURL := os.Getenv(CalyptiaEnvAPIURL); apiURL != "" { + c.BaseURL = apiURL + } + + // Set the ProjectToken if environment variable is set + if token := os.Getenv(CalyptiaEnvAPIToken); token != "" { + c.SetProjectToken(token) + } + return c +} + // SetUserAgent sets the "User-Agent" header of the client. func (c *Client) SetUserAgent(s string) { c.userAgent = s diff --git a/spec/open-api.yml b/spec/open-api.yml index 8475146..89cb410 100644 --- a/spec/open-api.yml +++ b/spec/open-api.yml @@ -3953,6 +3953,19 @@ components: example: "My template" definition: $ref: "#/components/schemas/ProcessingRuleDef" + pipelineVersion: + type: string + example: v1.3.5 + description: semver version of core-fluent-bit is running + input: + type: string + example: {"log": "line 2"} + maxLength: 1048576 + minimum: 1 + description: input to use as an example for the processing rule template + isRawInput: + type: boolean + description: define if the input parameter is in raw or json format (false) createdAt: type: string format: date-time