kprav33n / appd-cloud-go-client

A Golang client SDK to interact with AppDynamics Cloud

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

A Golang client SDK to interact with AppDynamics Cloud

License:Mozilla Public License 2.0


Languages

Language:Mustache 95.7%Language:Shell 4.3%