Categorygithub.com/cisco-open/appd-cloud-go-client
modulepackage
1.0.2
Repository: https://github.com/cisco-open/appd-cloud-go-client.git
Documentation: pkg.go.dev

# 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.

# Packages

No description provided by the author

# Functions

No description provided by the author
NewConfiguration returns a new Configuration object.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author

# Variables

ContextAccessToken takes a string oauth2 access token as authentication for the request.
ContextAPIKeys takes a string apikey as authentication for the request.
ContextBasicAuth takes BasicAuth as authentication for the request.
ContextHttpSignatureAuth takes HttpSignatureAuth as authentication for the request.
ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
ContextOperationServerIndices uses a server configuration from the index mapping.
ContextOperationServerVariables overrides a server configuration variables using operation specific values.
ContextServerIndex uses a server configuration from the index.
ContextServerVariables overrides a server configuration variables.

# Structs

APIKey provides API key based authentication to a request passed via context using ContextAPIKey.
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth.
Configuration stores the configuration of the API client.
ServerConfiguration stores the information about a server.
ServerVariable stores the information about a server variable.

# Type aliases

ServerConfigurations stores multiple ServerConfiguration items.