Skip to content

akinross/aci-go-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aci-go-client

This repository contains the golang client SDK to interact with CISCO APIC using REST API calls. This SDK is used by terraform-provider-aci.

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/ciscoecosystem/aci-go-client

There are no additional dependancies needed to be installed.

Overview

  • client :- This package contains the HTTP Client configuration as well as service methods which serves the CRUD operations on the Model Objects in CISCO ACI.

  • models :- This package contains all the models structs and utility methods for the same.

  • tests :- This package contains the unit tests for the CRUD operations that can be performed on the Model Objects.

How to Use

import the client in your go application and retrive the client object by calling client.GetClient() method.

import github.com/ciscoecosystem/aci-go-client/v2/client
client.GetClient("URL", "Username", client.Password("Password"), client.Insecure(true/false))

aci-go-client supports signature based authentication also. To use signature based authentication call the GetClient method as follows.

client.GetClient("URL", "Username", client.PrivateKey("PrivateKey path"),client.AdminCert("Certificate name"), client.Insecure(true/false))

Use that client object to call the service methods to perform the CRUD operations on the model objects.

Example,

    client.CreateTenant("tenant_name","description",tenantAttributesStruct)
    # tenantAttributesStruct is struct present in models/fv_tenant.go

aci-go-client supports concurrent connections to different targets by calling client.NewClient() instead of client.GetClient().

client.NewClient("URL", "Username", client.PrivateKey("PrivateKey path"),client.AdminCert("Certificate name"), client.Insecure(true/false))

When making PyQuery calls (API calls which start with /mqapi2/), ensure that the APIC-Cookie is populated in the Requests as PyQuery may not function using only the Certificate-Based Request.

If using Username/Password, no extra steps are necessary, as the APIC-Cookie will be obtained at the time of the API call. If using Certificate based authentication, call client.Authenticate() first, to obtain a recent APIC-Cookie authorization token PyQuery APIs currently do not support Certificate + Username authentication.

client.NewClient("URL", "Username", client.AppUserName("AppUserName"), client.PrivateKey("PrivateKey path"), client.AdminCert("Certificate name"), client.Insecure(true/false))

When using client.Do() or client.DoRaw() with large payloads (like files), set the client.MaxRetries to 0 (if configured to another value) to avoid reading the complete payload into memory. You might also want to set client.SkipLoggingPayload(true) before executing the client.Do() or client.DoRaw().

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%