client

package module
v1.10.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 21 Imported by: 1

README

Community Go Client for STACKIT

Go Report Card Unit Tests Coverage Status GoDoc reference License


The client is community-supported and not an official STACKIT release, it is maintained by internal Schwarz IT teams integrating with STACKIT

Install

To install the latest stable release, run:

go get github.com/SchwarzIT/community-stackit-go-client@latest

Usage Example

In order to use the client, a STACKIT Service Account must be created and have relevant roles assigned to it.
For further assistance, please contact STACKIT support

package main

import (
	"context"
	"fmt"
	"os"

	client "github.com/SchwarzIT/community-stackit-go-client"
	"github.com/SchwarzIT/community-stackit-go-client/pkg/validate"
)

func main() {
	ctx := context.Background()
	c, err := client.New(ctx, client.Config{
		ServiceAccountEmail: os.Getenv("STACKIT_SERVICE_ACCOUNT_EMAIL"),
		ServiceAccountToken: os.Getenv("STACKIT_SERVICE_ACCOUNT_TOKEN"),
	})
	if err != nil {
		panic(err)
	}

	projectID := "123-456-789"
	res, err := c.ElasticSearch.Offerings.GetWithResponse(ctx, projectID)
	if aggregatedError := validate.Response(res, err, "JSON200"); aggregatedError != nil {
		panic(aggregatedError)
	}

	fmt.Println("Received the following offerings:")
	for _, o := range res.JSON200.Offerings {
		fmt.Printf("- %s\n", o.Name)
	}
}

Further usage examples can be found in terraform-provider-stackit

Documentation

Index

Constants

View Source
const (
	ClientTimeoutErr         = "Client.Timeout exceeded while awaiting headers"
	ClientContextDeadlineErr = "context deadline exceeded"
	ClientEOFError           = "unexpected EOF"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {

	// when an internal server error is encountered
	// the call will be retried
	RetryTimout time.Duration // timeout for retrying a call
	RetryWait   time.Duration // how long to wait before trying again
	// contains filtered or unexported fields
}

Client service for managing interactions with STACKIT API

func MockServer

func MockServer() (c *Client, mux *http.ServeMux, teardown func(), err error)

MockServer mocks STACKIT api server and returns a client pointing to it, mux, teardown function and an error indicator

func New

func New(ctx context.Context, cfg Config) (*Client, error)

New returns a new client

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) GetBaseURL added in v1.1.0

func (c *Client) GetBaseURL() string

GetBaseURL returns the base url string

func (*Client) GetConfig

func (c *Client) GetConfig() Config

GetConfig returns the client config

func (*Client) GetHTTPClient

func (c *Client) GetHTTPClient() *http.Client

GetHTTPClient returns the HTTP client

func (*Client) LegacyDo added in v1.3.0

func (c *Client) LegacyDo(req *http.Request, v interface{}, errorHandlers ...func(*http.Response) error) (*http.Response, error)

LegacyDo performs the request, including retry if set To set retry, use WithRetry() which returns a shalow copy of the client

func (*Client) Request

func (c *Client) Request(ctx context.Context, method, path string, body []byte) (*http.Request, error)

Request creates a new API request

func (*Client) SetBaseURL added in v1.1.0

func (c *Client) SetBaseURL(url string) error

SetBaseURL sets the base url

func (*Client) SetToken

func (c *Client) SetToken(token string)

type Config

type Config struct {
	BaseUrl             *url.URL
	ServiceAccountToken string
	ServiceAccountEmail string
}

Config is the STACKIT client configuration

func (*Config) SetURL

func (c *Config) SetURL(value string) error

SetURL sets a given url string as the base url in the config if the given value is empty, the default base URL will be used

func (*Config) Validate

func (c *Config) Validate() error

Validate verifies that the given config is valid

Directories

Path Synopsis
examples
internal
common
client file in package common holds the client interface and service struct used by each service that the client is connecting with services using the Service struct are located under pkg/api
client file in package common holds the client interface and service struct used by each service that the client is connecting with services using the Service struct are located under pkg/api
pkg
services/argus/v1.0/generated
Package argus provides primitives to interact with the openapi HTTP API.
Package argus provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/acl
Package acl provides primitives to interact with the openapi HTTP API.
Package acl provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/alert-config
Package alertconfig provides primitives to interact with the openapi HTTP API.
Package alertconfig provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/alert-groups
Package alertgroups provides primitives to interact with the openapi HTTP API.
Package alertgroups provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/alert-records
Package alertrecords provides primitives to interact with the openapi HTTP API.
Package alertrecords provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/alert-rules
Package alertrules provides primitives to interact with the openapi HTTP API.
Package alertrules provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/backup
Package backup provides primitives to interact with the openapi HTTP API.
Package backup provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/cert-check
Package certcheck provides primitives to interact with the openapi HTTP API.
Package certcheck provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/grafana-configs
Package grafanaconfigs provides primitives to interact with the openapi HTTP API.
Package grafanaconfigs provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/http-check
Package httpcheck provides primitives to interact with the openapi HTTP API.
Package httpcheck provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/instances
Package instances provides primitives to interact with the openapi HTTP API.
Package instances provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/logs
Package logs provides primitives to interact with the openapi HTTP API.
Package logs provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/metrics-storage-retention
Package metricsstorageretention provides primitives to interact with the openapi HTTP API.
Package metricsstorageretention provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/network-check
Package networkcheck provides primitives to interact with the openapi HTTP API.
Package networkcheck provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/ping-check
Package pingcheck provides primitives to interact with the openapi HTTP API.
Package pingcheck provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/plans
Package plans provides primitives to interact with the openapi HTTP API.
Package plans provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/scrape-config
Package scrapeconfig provides primitives to interact with the openapi HTTP API.
Package scrapeconfig provides primitives to interact with the openapi HTTP API.
services/argus/v1.0/generated/traces
Package traces provides primitives to interact with the openapi HTTP API.
Package traces provides primitives to interact with the openapi HTTP API.
services/data-services/v1.0/generated
Package dataservices provides primitives to interact with the openapi HTTP API.
Package dataservices provides primitives to interact with the openapi HTTP API.
services/data-services/v1.0/generated/credentials
Package credentials provides primitives to interact with the openapi HTTP API.
Package credentials provides primitives to interact with the openapi HTTP API.
services/data-services/v1.0/generated/instances
Package instances provides primitives to interact with the openapi HTTP API.
Package instances provides primitives to interact with the openapi HTTP API.
services/data-services/v1.0/generated/offerings
Package offerings provides primitives to interact with the openapi HTTP API.
Package offerings provides primitives to interact with the openapi HTTP API.
services/kubernetes/v1.0/generated
Package kubernetes provides primitives to interact with the openapi HTTP API.
Package kubernetes provides primitives to interact with the openapi HTTP API.
services/kubernetes/v1.0/generated/cluster
Package cluster provides primitives to interact with the openapi HTTP API.
Package cluster provides primitives to interact with the openapi HTTP API.
services/kubernetes/v1.0/generated/credentials
Package credentials provides primitives to interact with the openapi HTTP API.
Package credentials provides primitives to interact with the openapi HTTP API.
services/kubernetes/v1.0/generated/operation
Package operation provides primitives to interact with the openapi HTTP API.
Package operation provides primitives to interact with the openapi HTTP API.
services/kubernetes/v1.0/generated/project
Package project provides primitives to interact with the openapi HTTP API.
Package project provides primitives to interact with the openapi HTTP API.
services/kubernetes/v1.0/generated/provider-options
Package provideroptions provides primitives to interact with the openapi HTTP API.
Package provideroptions provides primitives to interact with the openapi HTTP API.
services/membership/v2.0/generated
Package membership provides primitives to interact with the openapi HTTP API.
Package membership provides primitives to interact with the openapi HTTP API.
services/membership/v2.0/generated/membership
Package membership provides primitives to interact with the openapi HTTP API.
Package membership provides primitives to interact with the openapi HTTP API.
services/membership/v2.0/generated/private
Package private provides primitives to interact with the openapi HTTP API.
Package private provides primitives to interact with the openapi HTTP API.
services/membership/v2.0/generated/public
Package public provides primitives to interact with the openapi HTTP API.
Package public provides primitives to interact with the openapi HTTP API.
services/mongodb-flex/v1.0/generated
Package mongodbflex provides primitives to interact with the openapi HTTP API.
Package mongodbflex provides primitives to interact with the openapi HTTP API.
services/mongodb-flex/v1.0/generated/backup
Package backup provides primitives to interact with the openapi HTTP API.
Package backup provides primitives to interact with the openapi HTTP API.
services/mongodb-flex/v1.0/generated/flavors
Package flavors provides primitives to interact with the openapi HTTP API.
Package flavors provides primitives to interact with the openapi HTTP API.
services/mongodb-flex/v1.0/generated/instance
Package instance provides primitives to interact with the openapi HTTP API.
Package instance provides primitives to interact with the openapi HTTP API.
services/mongodb-flex/v1.0/generated/storage
Package storage provides primitives to interact with the openapi HTTP API.
Package storage provides primitives to interact with the openapi HTTP API.
services/mongodb-flex/v1.0/generated/user
Package user provides primitives to interact with the openapi HTTP API.
Package user provides primitives to interact with the openapi HTTP API.
services/mongodb-flex/v1.0/generated/versions
Package versions provides primitives to interact with the openapi HTTP API.
Package versions provides primitives to interact with the openapi HTTP API.
services/postgres-flex/v1.0/generated
Package postgresflex provides primitives to interact with the openapi HTTP API.
Package postgresflex provides primitives to interact with the openapi HTTP API.
services/postgres-flex/v1.0/generated/backups
Package backups provides primitives to interact with the openapi HTTP API.
Package backups provides primitives to interact with the openapi HTTP API.
services/postgres-flex/v1.0/generated/flavors
Package flavors provides primitives to interact with the openapi HTTP API.
Package flavors provides primitives to interact with the openapi HTTP API.
services/postgres-flex/v1.0/generated/instance
Package instance provides primitives to interact with the openapi HTTP API.
Package instance provides primitives to interact with the openapi HTTP API.
services/postgres-flex/v1.0/generated/storage
Package storage provides primitives to interact with the openapi HTTP API.
Package storage provides primitives to interact with the openapi HTTP API.
services/postgres-flex/v1.0/generated/users
Package users provides primitives to interact with the openapi HTTP API.
Package users provides primitives to interact with the openapi HTTP API.
services/postgres-flex/v1.0/generated/versions
Package versions provides primitives to interact with the openapi HTTP API.
Package versions provides primitives to interact with the openapi HTTP API.
services/resource-management/v2.0/generated
Package resourcemanagement provides primitives to interact with the openapi HTTP API.
Package resourcemanagement provides primitives to interact with the openapi HTTP API.
services/resource-management/v2.0/generated/private
Package private provides primitives to interact with the openapi HTTP API.
Package private provides primitives to interact with the openapi HTTP API.
services/resource-management/v2.0/generated/projects
Package projects provides primitives to interact with the openapi HTTP API.
Package projects provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL