client

package module
v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0 Imports: 22 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)
	}

	res, err := c.ElasticSearch.Offerings.GetWithResponse(ctx, "{project-id}")
	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 Examples
  1. Under /examples directory
  2. In our terraform-provider-stackit

Working with API environments

In order to modify the API environment, set the Environment field to one of dev, qa or prod

  • The Environment field is optional
  • By default prod is being used
c, err := client.New(ctx, client.Config{
	// ...
	Environment: "qa"
})

Documentation

Index

Constants

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

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) GetConfig

func (c *Client) GetConfig() Config

GetConfig returns the client config

func (*Client) GetEnvironment added in v1.12.1

func (c *Client) GetEnvironment() common.Environment

GetEnvironment returns the client environment

func (*Client) GetHTTPClient

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

GetHTTPClient returns the HTTP client

type Config

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

Config is the STACKIT client configuration

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/costs/v1.0/generated
Package costs provides primitives to interact with the openapi HTTP API.
Package costs provides primitives to interact with the openapi HTTP API.
services/costs/v2.0/generated
Package costs provides primitives to interact with the openapi HTTP API.
Package costs 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/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/object-storage/v1.0.1/generated
Package objectstorage provides primitives to interact with the openapi HTTP API.
Package objectstorage provides primitives to interact with the openapi HTTP API.
services/object-storage/v1.0.1/generated/access-key
Package accesskey provides primitives to interact with the openapi HTTP API.
Package accesskey provides primitives to interact with the openapi HTTP API.
services/object-storage/v1.0.1/generated/bucket
Package bucket provides primitives to interact with the openapi HTTP API.
Package bucket provides primitives to interact with the openapi HTTP API.
services/object-storage/v1.0.1/generated/credentials-group
Package credentialsgroup provides primitives to interact with the openapi HTTP API.
Package credentialsgroup provides primitives to interact with the openapi HTTP API.
services/object-storage/v1.0.1/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/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.
services/service-accounts/v2.0/generated
Package serviceaccounts provides primitives to interact with the openapi HTTP API.
Package serviceaccounts provides primitives to interact with the openapi HTTP API.
urls
urls is used to manage base urls for every STACKIT environment
urls is used to manage base urls for every STACKIT environment

Jump to

Keyboard shortcuts

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