goCentral is a Go SDK/package that an interface to the HPE/Aruba Networks Central network management system. This project is at its start and will continue to add functionality over time. It will strive to offer the same functionality for golang as the pyCentral (https://github.com/aruba/pycentral) SDK offers for Python applications.
If you wish to become a contributor and help to grow this SDK, please contact the author.
goCentral provides a token management system to stores the operational token information in an AES encrypted file as to not require the acquisition of a new token each time an application is executed. It will handle the refresh of expired tokens when required, but must first be initialized using the Init_DB function. This function will prompt for the addition of the following information:
- Central API URL
- Customer ID
- Client ID
- Client secret
- Access token (this is the current, valid access token)
- Refresh token
Since the data stored and read by Write_DB and Read_DB is encrypted/decryptes using AES encryption, an encryption passphrase is needed. The library has a default passphrase; however, it is strongly advised to set a unique passphrase when building applications using this library. Setting a passphrase is done by adding the following line in each application:
- goCentral.Passphrase = "Understanding is a three edged sword. Your side, their side, and the truth. - Kosh"
Once set, the passphrase will be used when reading and writing to the secure storage DB. If multiple applications are using the same secure storage DB, they should all use the same passphrase.
- Description: Encrypts the provided data using the given passphrase.
- Parameters:
data
: The data to be encrypted.Passphrase
: The passphrase used for encryption.
- Returns: The encrypted data as a byte slice.
- Description: Decrypts the provided data using the given passphrase.
- Parameters:
data
: The data to be decrypted.Passphrase
: The passphrase used for decryption.
- Returns: The decrypted data as a byte slice.
- Description: Refreshes the API token for the provided
Central_struct
. - Parameters:
central_info
: TheCentral_struct
containing the necessary information for refreshing the token.
- Returns:
- The HTTP status code.
- The new access token.
- The new refresh token.
- The expiration time in seconds.
- Description: Tests the connectivity to the central API using the provided
Central_struct
. - Parameters:
central_info
: TheCentral_struct
containing the necessary information for testing the API.
- Returns:
- The HTTP status code.
- The access token.
- The refresh token.
- Description: Reads the central information from the YAML file specified by
filename
and returns it as aCentral_struct
. - Parameters:
filename
: The path to the YAML file containing the central information.
- Returns: The
Central_struct
containing the central information.
- Description: Writes the provided
Central_struct
to the YAML file specified byfilename
. - Parameters:
filename
: The path to the YAML file where the central information will be written.central_info_global
: TheCentral_struct
containing the central information to be written.
- Returns: An integer indicating the success or failure of the write operation (0 for success, 1 for failure).
- Description: Initializes the central database by prompting the user to enter the required information and writing it to the specified YAML file.
- Parameters:
filename
: The path to the YAML file where the central information will be written.