apis

package module
v2.1.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MPL-2.0 Imports: 6 Imported by: 0

README

appd-cloud-go-client

This repository contains the golang client SDK to interact with AppDynamics Cloud using REST API calls. This SDK is used by terraform-provider-appd.

Installation

Use go get to retrieve the SDK to add it to your GOPATH workspace, or project's Go module dependencies:

go get github.com/cisco-open/appd-cloud-go-client

There are no additional dependencies that need to be installed.

Overview

  • apis :- This package contains the client package of a specific API version generated by the OpenAPI client generator.

  • custom-templates :- This folder contains the custom mustache template files.

  • .openapi-generator-ignore :- This file contains the information about individual files or directories that can be ignored.

  • apis.txt :- This file contains the URLs of the Open API Spec for the AppDynamics Cloud.

  • config.yaml :- This file contains all the additional configuration settings that are needed to generate Go Client SDK.

  • configuration.go :- This file contains all configuration of the API Client.

  • script.sh :- This file contains the script which leads to the generation of the Go Client SDK.

How to Use

Get the specific API Client through which REST call can be made to access the resource. Below is the example of fetching a Connection for a specific CONNECTION_ID using Cloud Connection API Client.

import (
    "fmt"
    "context"
    "strings"
    client "github.com/cisco-open/appd-cloud-go-client"
    cloudconnectionapi "github.com/cisco-open/appd-cloud-go-client/apis/v1/cloudconnections"
)

// Get the configuration object
configuration := client.NewConfiguration()

// ContextServerVariables override the server configuration variables
ctx := context.WithValue(context.Background(), client.ContextServerVariables, map[string]string{
    "tenant-name": tenantName,
})
// Set Access Token in the context required for authentication for the request
ctx = context.WithValue(ctx, client.ContextAccessToken, "TOKEN")

// Create a new API Client for accessing the Cloud Connection API.
apiClient := cloudconnectionapi.NewAPIClient(configuration)

// Set ContextServerIndex in the context which uses a server configuration for the index of Cloud Connection.
ctx := context.WithValue(ctx, client.ContextServerIndex, client.SERVER_INDEX_CLOUD_CONNECTION)

// GET Request using API Client to get the connection information for a specific connection id.
resp, httpResp, err := apiClient.ConnectionsApi.GetConnection(ctx, "CONNECTION_ID").Execute()
if err != nil {
    fmt.Printf("Err: %v", err)
}

Adding New Functionality

In case of adding the new functionality support for new API, you will need to update apis.txt file with the API Spec link in the file. OpenAPI Generator is responsible for generation of Go Client SDK as per the changes in the apis.txt file.

Documentation

Index

Constants

View Source
const (
	SERVER_INDEX_CLOUD_CONNECTION                 = 0
	SERVER_INDEX_APPLICATION_PRINCIPAL_MANAGEMENT = 1
	SERVER_INDEX_CLOUD_QUERY                      = 2
)

Variables

View Source
var (
	// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKeys takes a string apikey as authentication for the request
	ContextAPIKeys = contextKey("apiKeys")

	// ContextHttpSignatureAuth takes HttpSignatureAuth as authentication for the request.
	ContextHttpSignatureAuth = contextKey("httpsignature")

	// ContextServerIndex uses a server configuration from the index.
	ContextServerIndex = contextKey("serverIndex")

	// ContextOperationServerIndices uses a server configuration from the index mapping.
	ContextOperationServerIndices = contextKey("serverOperationIndices")

	// ContextServerVariables overrides a server configuration variables.
	ContextServerVariables = contextKey("serverVariables")

	// ContextOperationServerVariables overrides a server configuration variables using operation specific values.
	ContextOperationServerVariables = contextKey("serverOperationVariables")
)

Functions

func DumpNonSensitive

func DumpNonSensitive(req string) string

Types

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration

type Configuration struct {
	Host             string            `json:"host,omitempty"`
	Scheme           string            `json:"scheme,omitempty"`
	DefaultHeader    map[string]string `json:"defaultHeader,omitempty"`
	UserAgent        string            `json:"userAgent,omitempty"`
	Debug            bool              `json:"debug,omitempty"`
	Servers          ServerConfigurations
	OperationServers map[string]ServerConfigurations
	HTTPClient       *http.Client
}

Configuration stores the configuration of the API client

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration returns a new Configuration object

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

AddDefaultHeader adds a new HTTP header to the default header in the request

func (*Configuration) ServerURL

func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error)

ServerURL returns URL based on server settings

func (*Configuration) ServerURLWithContext

func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error)

ServerURLWithContext returns a new server URL given an endpoint

type ServerConfiguration

type ServerConfiguration struct {
	URL         string
	Description string
	Variables   map[string]ServerVariable
}

ServerConfiguration stores the information about a server

type ServerConfigurations

type ServerConfigurations []ServerConfiguration

ServerConfigurations stores multiple ServerConfiguration items

func (ServerConfigurations) URL

func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error)

URL formats template on a index using given variables

type ServerVariable

type ServerVariable struct {
	Description  string
	DefaultValue string
	EnumValues   []string
}

ServerVariable stores the information about a server variable

Directories

Path Synopsis
apis

Jump to

Keyboard shortcuts

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