Ruby client library to interact with various IBM Cloud VPC APIs.
Disclaimer: this SDK is being released initially as a pre-release version. Changes might occur which impact applications that use this SDK.
- Overview
- Prerequisites
- Installation
- Using the SDK
- Questions
- Issues
- Open source @ IBM
- Contributing
- License
The IBM Cloud VPC Ruby SDK allows developers to programmatically interact with the following IBM Cloud services:
Service Name | Imported Class Name |
---|---|
VPC | IbmVpc::VpcV1 |
- An IBM Cloud account.
- An IAM API key to allow the SDK to access your account. Create one here.
- Ruby 2.3.0 or above.
To install, use gem
gem install "ibm_vpc"
For general SDK usage information, please see this link
require "ibm_vpc"
# First select an authentication type (IAM, Bearer, etc...)
# See https://github.com/IBM/ibm-cloud-sdk-common/blob/master/README.md#authentication for
# a full list of available authenticators.
# IAM example
authenticator = IbmVpc::Authenticators::IamAuthenticator.new(
apikey: "<iam_apikey>",
url: "<iam_url>" # optional - the default value is https://iam.cloud.ibm.com/identity/token
)
# Bearer Token example
authenticator = IbmVpc::Authenticators::BearerTokenAuthenticator.new(
bearer_token: "<access_token>"
)
Setting up and using the API client is simple, just pass in your authenticator object and then you can issue API calls:
# Pass the authenticator into the VpcV1 service
vpc_v1 = IbmVpc::VpcV1.new(
version: "2023-12-19" # Will default to the latest version if not specified
authenticator: authenticator
)
# Now you can start to make API calls
response = vpc_v1.list_instances()
response["instances"].each do |instance|
puts instance["name"]
end
If a collection response has a lot of items in it, the results will be paginated.
start = nil
instances = []
loop do
response = vpc_v1.list_instances(start: start)
instances += response["instances"]
next_link = response.dig("next", "href")
break if next_link.nil?
start = CGI.parse(URI(next_link).query)["start"].first
end
If you are having difficulties using this SDK or have a question about the IBM Cloud services, please ask a question Stack Overflow.
If you encounter an issue with the project, you are welcome to submit a bug report. Before that, please search for similar issues. It's possible that someone has already reported the problem.
Find more open source projects on the IBM Github Page
See CONTRIBUTING.md.
This SDK is released under the Apache 2.0 license. The license's full text can be found in LICENSE.