zestapi

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: MIT Imports: 14 Imported by: 0

README

ZEST Cloud Golang API

This project is based on OpenAPI generation, including additional functionallity for singing requests with HMAC key and secret.

Prerequisites

You will need a valid ACCESS_KEY and ACCESS_SECRET for your user from the Zest Cloud.

Usage

go get github.com/zestlabs-io/zest-go-sdk
import (
  sdk "github.com/zestlabs-io/zest-go-sdk"
  "github.com/go-openapi/strfmt"
  "github.com/zestlabs-io/zest-go-sdk/api/client"
  "github.com/zestlabs-io/zest-go-sdk/api/client/auth_service"
  "context"
  "fmt"
)

func main() {

  cl := sdk.NewHMACAPIClient(strfmt.Default, 
      &client.TransportConfig{
        Host: "dev.zestlabs.cloud", 
        Schemes: []string{"https"}}, 
      os.Getenv("ZEST_KEY"), 
      os.Getenv("ZEST_SECRET"))

  // Call Auth service to fetch the current account details 
  res, err := cl.AuthService.AuthServiceGetOwnAccount(&auth_service.AuthServiceGetOwnAccountParams{Context: ctx})
  
  if err != nil {
    panic(fmt.Errorf("Error getting account : %v", err))
  }
  
  fmt.Printf("Fetched own account with ID: %s", res.Payload.Account.AccountID)
}

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHMACAPIClient

func NewHMACAPIClient(formats strfmt.Registry, cfg *client.TransportConfig, cloudKey, cloudSecret string) *client.ZestAPI

Types

type SigningRoundTripper

type SigningRoundTripper struct {
	Proxied http.RoundTripper
	// contains filtered or unexported fields
}

This type implements the http.RoundTripper interface

func (SigningRoundTripper) RoundTrip

func (lrt SigningRoundTripper) RoundTrip(r *http.Request) (res *http.Response, e error)

Generates the authorization token in a form `ZEST cloudKey:HMAC_SIGN(<cloudSecret>, reqPath + '\n' + contentType + '\n' + validity + '\n' + md5Body)` This further should be passed as `Authorization` header

Jump to

Keyboard shortcuts

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