Introduction
sdk-go-bundle
Enables users of IONOS Cloud sdks to use one repo for all the GO SDKs released.
⚠️ Note: sdk-go-bundle is currently in the Early Access (EA) phase. For production or critical applications, we recommend using the older separate repo SDKs in the table below.
Go API client for ionoscloud
IONOS Enterprise-grade Infrastructure as a Service (IaaS) solutions can be managed through the Cloud API, in addition or as an alternative to the "Data Center Designer" (DCD) browser-based tool.
Both methods employ consistent concepts and features, deliver similar power and flexibility, and can be used to perform a multitude of management tasks, including adding servers, volumes, configuring networks, and so on.
Overview
The IONOS Cloud SDK for GO bundle provides you with access to the IONOS Cloud API. The client library supports both simple and complex requests. It is designed for developers who are building applications in GO . The SDK for GO wraps the IONOS Cloud API. All API operations are performed over SSL and authenticated using your IONOS Cloud portal credentials. The API can be accessed within an instance running in IONOS Cloud or directly over the Internet from any application that can send an HTTPS request and receive an HTTPS response.
List of all SDK products in sdk-go-bundle
, along with their equivalents in the separate repos
sdk-go-bundle
, along with their equivalents in the separate reposAuthentication
Use the Auth API to manage tokens for secure access to IONOS Cloud APIs (Auth API, Cloud API, Reseller API, Activity Log API, and others).
Compute
Use the Auth API to manage resources in the compute engine: datacenters, locations, servers, kubernetes resources, images, volumes, lans, ip blocks, network interfaces, private cross connects, firewall rules, flow logs, load balancers, nat gateways, network load balancers, application load balancers, target groups, s3 keys, snapshots, users, groups, labels, templates
DBaaS Mongo
You have the ability to quickly set up and manage a MongoDB database. You can also delete clusters, manage backups and users via the API. The MongoDB API allows you to create additional database clusters or modify existing ones.
DBaaS Postgres SQL
The API allows you to create additional PostgreSQL database clusters or modify existing ones.
Certificate Manager
Using the Certificate Manager product, you can conveniently provision and manage SSL certificates with IONOS services and your internal connected resources.
Container Registry
Container Registry product enables IONOS clients to manage docker and OCI compliant registries for use by their managed Kubernetes clusters. Use a Container Registry to ensure you have a privately accessed registry to efficiently support image pulls.
Data Platform
Managed Stackable Data Platform by IONOS Cloud provides a preconfigured Kubernetes cluster with pre-installed and managed Stackable operators. After the provision of these Stackable operators, the customer can interact with them directly and build his desired application on top of the Stackable Platform.
DNS
DNS allows users to publish DNS Zones of their domains and subdomains on public Name Servers.
Environment Variables
IONOS_USERNAME
Specify the username used to login, to authenticate against the IONOS Cloud API
IONOS_PASSWORD
Specify the password used to login, to authenticate against the IONOS Cloud API
IONOS_TOKEN
Specify the token used to login, if a token is being used instead of username and password
IONOS_API_URL
Specify the API URL. It will overwrite the API endpoint default value api.ionos.com
. Note: for compute, the host URL does not contain the /cloudapi/v6
path, so it should not be included in the IONOS_API_URL
environment variable
IONOS_LOG_LEVEL
Specify the Log Level used to log messages. Possible values: Off, Debug, Trace
IONOS_PINNED_CERT
Specify the SHA-256 public fingerprint here, enables certificate pinning
⚠️ Note: To overwrite the api endpoint - api.ionos.com
, the environment variable $IONOS_API_URL
can be set, and used with NewConfigurationFromEnv()
function.
Getting started
To start working with the SDK, set up your project for Go modules, and retrieve the SDK dependencies with go get
. This example shows how to use the SDK to make an API request to IONOS Cloud.
Create directory
Add SDK dependencies
Add the code:
Run the code
Using your IDE of choice, add the following code:
Token Authentication
There are 2 ways to generate your token:
Generate token using SDK go auth:
Generate token using ionosctl:
Install ionosctl as explained here Run commands to log in and generate your token.
Save the generated token and use it to authenticate:
Certificate pinning:
You can enable certificate pinning if you want to bypass the normal certificate checking procedure, by doing the following:
Set env variable IONOS_PINNED_CERT=<insert_sha256_public_fingerprint_here>
You can get the sha256 fingerprint most easily from the browser by inspecting the certificate.
Debugging
You can inject any logger that implements Printf instead of using the default sdk logger. There are log levels that you can set: Off
, Debug
and Trace
.
Off
Does not show any logs
Debug
Regular logs, no sensitive information
Trace
Logs everything, the full request(along with authentication) and response without encryption.
⚠️ Note: We recommend you only set this TRACE
for debugging purposes. Disable it in your production environments because it can log sensitive data.
It logs the full request and response without encryption, even for an HTTPS call.
Verbose request and response logging can also significantly impact your application's performance.
Migration Guide
All SDKs are found in the folder https://github.com/ionos-cloud/sdk-go-bundle/tree/master/products
.
Structs moved to
shared
package:GenericOpenAPIError
,Configuration
,APIResponse
, utility functions, logging interface, environment variables.Import
github.com/ionos-cloud/sdk-go-bundle/shared
and replace the structs as required.IONOS_DEBUG removed, debugging now set with
IONOS_LOG_LEVEL
, as described hereReplaced
PtrBool
,PtrInt
,PtrInt32
,PtrInt64
,PtrFloat
,PtrFloat32
,PtrFloat64
,PtrString
,PtrTime
withToPtr
generic functionsFor CloudAPI,
computeconfig.SetDepth(int32(1))
is removed, you should instead usesharedconfig.AddDefaultQueryParam("depth", "1")
Example migration for compute github.com/ionos-cloud/sdk-go/v6
to github.com/ionos-cloud/sdk-go-bundle/products/compute
Replace the import ionoscloud
github.com/ionos-cloud/sdk-go/v6
withgithub.com/ionos-cloud/sdk-go-bundle/products/compute
You will get errors, as some structs have been moved theshared
packageImport
github.com/ionos-cloud/sdk-go-bundle/shared
and replace the structs as required. Examples:var apiResponse *ionoscloud.APIResponse
withvar apiResponse *shared.APIResponse
ionoscloud.NewConfiguration(username, password, token, url)
withshared.NewConfiguration(username, password, token, url)
Logger
no longer a part of theConfiguration
object, it is a global instance calledSdkLogger
, that can be set using shared.Logger =logger of your choice
LogLevel
no longer a part of theConfiguration
object, it is a global instance calledSdkLogLevel
, that can be set usingshared.SdkLogLevel
All replacements work as-is, no other changes are required.
Last updated