gravitee

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2018 License: MIT Imports: 11 Imported by: 0

README

Gravitee Management API for Go

This library provides access to the Gravitee Management API (http://gravitee.io/).

Click here to open the GoDoc documentation.

Usage

To use the API, simply create a new session:

import "github.com/konsorten/go-gravitee"

func main() {
    session, _ := zevenet.Connect("api.mygravitee.com", "admin", "admin", nil)

    apis, _ := session.GetAllAPIs()
}

Authors

The library is sponsored by the marvin + konsorten GmbH.

It is loosely based on the go-bigip package by Scott Ware (and others).

We thank all the authors who provided code to this library:

  • Felix Kollmann

License

(The MIT License)

Copyright (c) 2018 marvin + konsorten GmbH (open-source@konsorten.de)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Package gravitee provides access to the Gravitee Management API (http://gravitee.io/).

More information is available on the project website: https://github.com/konsorten/go-gravitee/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIRequest

type APIRequest struct {
	Method      string
	URL         string
	Body        string
	ContentType string
}

APIRequest builds our request before sending it to the server.

type ApiDetails

type ApiDetails struct {
	ID          string        `json:"id"`
	Name        string        `json:"name"`
	Version     string        `json:"version"`
	Description string        `json:"description"`
	Visibility  ApiVisibility `json:"visibility"`
	State       ApiState      `json:"state"`
	Tags        []string      `json:"tags"`
	Labels      []string      `json:"labels"`
	//Paths       map[string]ApiDetailsPath `json:"paths"`
	CreatedAt   int           `json:"created_at"`
	UpdatedAdd  int           `json:"updated_at"`
	DeployedAt  int           `json:"deployed_at"`
	Owner       UserReference `json:"owner"`
	PictureURL  string        `json:"picture_url"`
	ContextPath string        `json:"context_path"`
	Proxy       struct {
		ContextPath      string               `json:"context_path"`
		StripContextPath bool                 `json:"strip_context_path"`
		LoggingMode      string               `json:"loggingMode"`
		Endpoints        []ApiDetailsEndpoint `json:"endpoints"`

		LoadBalancing struct {
			Type string `json:"type"`
		} `json:"load_balancing"`

		CORS struct {
			IsEnabled        bool     `json:"enabled"`
			AllowCredentials bool     `json:"allowCredentials"`
			AllowHeaders     []string `json:"allowHeaders"`
			AllowMethods     []string `json:"allowMethods"`
			AllowOrigin      []string `json:"allowOrigin"`
			ExposeHeaders    []string `json:"exposeHeaders"`
			MaxAgeSeconds    int      `json:"maxAge"`
		} `json:"cors"`
	} `json:"proxy"`
}

func (ApiDetails) String

func (ai ApiDetails) String() string

type ApiDetailsEndpoint

type ApiDetailsEndpoint struct {
	Name     string                 `json:"name"`
	Target   string                 `json:"target"`
	Weight   int                    `json:"weight"`
	IsBackup bool                   `json:"backup"`
	Type     string                 `json:"type"`
	Http     ApiDetailsEndpointHttp `json:"http"`
	SSL      ApiDetailsEndpointSSL  `json:"ssl"`
}

func MakeApiDetailsEndpoint

func MakeApiDetailsEndpoint(name, target string) ApiDetailsEndpoint

func (ApiDetailsEndpoint) String

func (ai ApiDetailsEndpoint) String() string

type ApiDetailsEndpointHttp

type ApiDetailsEndpointHttp struct {
	ConnectTimeoutMS         int  `json:"connectTimeout"`
	IdleTimeoutMS            int  `json:"idleTimeout"`
	ReadTimeoutMS            int  `json:"readTimeout"`
	KeepAlive                bool `json:"keepAlive"`
	Pipelining               bool `json:"pipelining"`
	MaxConcurrentConnections int  `json:"maxConcurrentConnections"`
	UseCompression           bool `json:"useCompression"`
	FollowRedirects          bool `json:"followRedirects"`
}

type ApiDetailsEndpointSSL

type ApiDetailsEndpointSSL struct {
	IsEnabled                  bool   `json:"enabled"`
	TrustAllCertificates       bool   `json:"trustAll"`
	VerifyHostnameInPublicCert bool   `json:"hostnameVerifier"`
	PublicCertPEM              string `json:"pem"`
}

type ApiDetailsPath

type ApiDetailsPath struct {
}

type ApiInfo

type ApiInfo struct {
	ID              string        `json:"id"`
	Name            string        `json:"name"`
	Version         string        `json:"version"`
	Description     string        `json:"description"`
	Visibility      ApiVisibility `json:"visibility"`
	State           ApiState      `json:"state"`
	Views           []string      `json:"views"`
	Labels          []string      `json:"labels"`
	Manageable      bool          `json:"manageable"`
	NumberOfRatings int           `json:"numberOfRatings"`
	CreatedAt       int           `json:"created_at"`
	UpdatedAdd      int           `json:"updated_at"`
	Owner           UserReference `json:"owner"`
	PictureURL      string        `json:"picture_url"`
	ContextPath     string        `json:"context_path"`
}

func (ApiInfo) String

func (ai ApiInfo) String() string

type ApiMetadata

type ApiMetadata struct {
	Key          string            `json:"key"`
	Name         string            `json:"name"`
	Format       ApiMetadataFormat `json:"format"`
	LocalValue   string            `json:"value"`
	DefaultValue string            `json:"defaultValue,omitempty"`
	ApiID        string            `json:"apiId,omitempty"`
}

func (ApiMetadata) IsLocal

func (ai ApiMetadata) IsLocal() bool

func (ApiMetadata) String

func (ai ApiMetadata) String() string

func (ApiMetadata) Value

func (ai ApiMetadata) Value() string

type ApiMetadataFormat

type ApiMetadataFormat string

ApiMetadataFormat is an enumeration of possible *Format* to be used for an API metdata entry.

const (
	ApiMetadataFormat_String  ApiMetadataFormat = "string"
	ApiMetadataFormat_Numeric ApiMetadataFormat = "numeric"
	ApiMetadataFormat_Boolean ApiMetadataFormat = "boolean"
	ApiMetadataFormat_Date    ApiMetadataFormat = "date"
	ApiMetadataFormat_Mail    ApiMetadataFormat = "mail"
	ApiMetadataFormat_URL     ApiMetadataFormat = "url"
)

type ApiState

type ApiState string

ApiState is an enumeration of possible *State* to be used for an API.

const (
	ApiState_Started ApiState = "started"
	ApiState_Stopped ApiState = "stopped"
)

type ApiVisibility

type ApiVisibility string

ApiVisibility is an enumeration of possible *Visibility* to be used for an API.

const (
	ApiVisibility_Private ApiVisibility = "private"
	ApiVisibility_Public  ApiVisibility = "public"
)

type ConfigOptions

type ConfigOptions struct {
	APICallTimeout time.Duration
}

ConfigOptions contains some advanced settings on server communication.

type GraviteeSession

type GraviteeSession struct {
	Host          string
	Authorization string
	Transport     *http.Transport
	ConfigOptions *ConfigOptions
}

GraviteeSession is a container for our session state.

func Connect

func Connect(host, username, password string, configOptions *ConfigOptions) (*GraviteeSession, error)

Connect sets up our connection to the Zevenet system.

func (*GraviteeSession) AddOrUpdateEndpoints

func (s *GraviteeSession) AddOrUpdateEndpoints(id string, endpoints []ApiDetailsEndpoint, replaceAll bool) error

AddOrUpdateEndpoints adds or updates an endpoint to an API registered in Gravitee.

func (*GraviteeSession) DeployAPI

func (s *GraviteeSession) DeployAPI(id string) error

DeployAPI deploys the current configuration of the API to the gateway instances.

func (*GraviteeSession) GetAPI

func (s *GraviteeSession) GetAPI(id string) (*ApiDetails, error)

GetAPI retrieves details on an API registered in Gravitee.

func (*GraviteeSession) GetAPIMetadata

func (s *GraviteeSession) GetAPIMetadata(id string) ([]ApiMetadata, error)

GetAPIMetadata retrieves the metadata on an API registered in Gravitee.

func (*GraviteeSession) GetAPIsByLabel

func (s *GraviteeSession) GetAPIsByLabel(label string) ([]ApiInfo, error)

GetAPIsByLabel retrieves a list of all APIs registered in Gravitee.

func (*GraviteeSession) GetAllAPIs

func (s *GraviteeSession) GetAllAPIs() ([]ApiInfo, error)

GetAllAPIs retrieves a list of all APIs registered in Gravitee.

func (*GraviteeSession) GetLocalAPIMetadata

func (s *GraviteeSession) GetLocalAPIMetadata(id string, metadataKey string) (*ApiMetadata, error)

GetLocalAPIMetadata retrieves a local metadata entry on an API registered in Gravitee.

func (*GraviteeSession) Ping

func (s *GraviteeSession) Ping() (bool, error)

Ping checks if the API is available.

func (*GraviteeSession) SetLocalAPIMetadata

func (s *GraviteeSession) SetLocalAPIMetadata(id string, metadataKey string, value string, format ApiMetadataFormat) error

SetLocalAPIMetadata updates or creates a local metadata entry on an API registered in Gravitee.

func (*GraviteeSession) String

func (s *GraviteeSession) String() string

String returns the session's hostname.

func (*GraviteeSession) UnsetLocalAPIMetadata

func (s *GraviteeSession) UnsetLocalAPIMetadata(id string, metadataKey string) error

UnsetLocalAPIMetadata removes a local metadata entry on an API registered in Gravitee.

type RequestError

type RequestError struct {
	Message    string `json:"message,omitempty"`
	HttpStatus int    `json:"http_status,omitempty"`
}

RequestError contains information about any error we get from a request.

func (RequestError) Error

func (r RequestError) Error() string

Error returns the error message.

type UserReference

type UserReference struct {
	Id          string `json:"id"`
	DisplayName string `json:"displayName"`
}

Jump to

Keyboard shortcuts

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