Introduction
Last updated
Last updated
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.
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.
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.
sdk-go-bundle
, along with their equivalents in the separate reposSDK Name | Sdk-go-bundle module | Full repo equivalent | Description |
---|---|---|---|
⚠️ Note: To overwrite the api endpoint - api.ionos.com
, the environment variable $IONOS_API_URL
can be set, and used with NewConfigurationFromEnv()
function.
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.
Using your IDE of choice, add the following code:
There are 2 ways to generate your token:
Install ionosctl as explained here Run commands to log in and generate your token.
Save the generated token and use it to authenticate:
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.
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
.
⚠️ 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.
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 here
Replaced PtrBool
, PtrInt
, PtrInt32
, PtrInt64
, PtrFloat
, PtrFloat32
, PtrFloat64
, PtrString
, PtrTime
with ToPtr
generic functions
For CloudAPI, computeconfig.SetDepth(int32(1))
is removed, you should instead use sharedconfig.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
with github.com/ionos-cloud/sdk-go-bundle/products/compute
You will get errors, as some structs have been moved the shared
package
Import github.com/ionos-cloud/sdk-go-bundle/shared
and replace the structs as required. Examples:
var apiResponse *ionoscloud.APIResponse
with var apiResponse *shared.APIResponse
ionoscloud.NewConfiguration(username, password, token, url)
with shared.NewConfiguration(username, password, token, url)
Logger
no longer a part of the Configuration
object, it is a global instance called SdkLogger
, that can be set using shared.Logger = logger of your choice
LogLevel
no longer a part of the Configuration
object, it is a global instance called SdkLogLevel
, that can be set using shared.SdkLogLevel
All replacements work as-is, no other changes are required.
Environment Variable | Description |
---|---|
Log level | Description |
---|---|
Authentication
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.
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
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.