Official Bare Metal Cloud SDK for Ruby. Use it to manage your Bare Metal Cloud resources by interacting with the Bare Metal Cloud API.
Bare Metal Cloud • Developers Portal • Knowledge Base • Support
Requirements
- Bare Metal Cloud account
- Ruby
Creating a Bare Metal Cloud account
- Go to the Bare Metal Cloud signup page.
- Follow the prompts to set up your account.
- Use your credentials to log in to Bare Metal Cloud portal.
▶️ Video tutorial: How to Create a Bare Metal Cloud Account
▶️ Video tutorial: Introduction to Bare Metal Cloud
Installing the Ruby SDK
The Bare Metal Cloud SDK for Ruby is split into 11 main gems. The following are all of the gems available:
pnap_audit_api
pnap_bmc_api
pnap_ip_api
pnap_network_api
pnap_network_storage_api
pnap_rancher_api
pnap_tag_api
pnap_location_api
pnap_billing_api
pnap_invoicing_api
pnap_payments_api
Each gem can be installed with the following command:
gem install <GEM_NAME>
Authentication
Each gem can be authenticated by configuring the SDK with an OAuth2 access token. The following is an example using the Audit API SDK:
require 'pnap_audit_api'
AuditApi.configure do |config|
config.access_token = 'YOUR ACCESS TOKEN'
end
The oauth2
library can also be used in order to generate a token using your Client ID and Client Secret.
# Load the gem
require 'pnap_audit_api'
require 'oauth2'
# Setup variables for getting a token.
client_id = 'YOUR_CLIENT_ID'
client_secret = 'YOUR_CLIENT_SECRET'
auth_url = 'https://auth.phoenixnap.com/auth/realms/BMC/protocol/openid-connect/token'
# Setup authorization
AuditApi.configure do |config|
# Retrieve the token using OAuth2.
client = OAuth2::Client.new(client_id, client_secret, token_url: auth_url)
token = client.client_credentials.get_token
# Configure OAuth2 access token for authorization: OAuth2
config.access_token = token.token
end
To get a Client ID and Client Secret, follow these steps:
- Log in to the Bare Metal Cloud portal.
- On the left side menu, click on API Credentials.
- Click the Create Credentials button.
- Fill in the Name and Description fields, select the permissions scope and click Create.
- In the table, click on Actions and select View Credentials from the dropdown.
- The values can be found in the Client ID and Client Secret fields.
Executing a Ruby script
Information on using each SDK can be found using its respective README:
pnap_audit_api
pnap_bmc_api
pnap_ip_api
pnap_network_api
pnap_network_storage_api
pnap_rancher_api
pnap_tag_api
pnap_location_api
pnap_billing_api
pnap_invoicing_api
pnap_payments_api
Bare Metal Cloud community
Become part of the Bare Metal Cloud community to get updates on new features, help us improve the platform, and engage with developers and other users.
- Follow @phoenixNAP on Twitter
- Join the official Slack channel
- Sign up for our Developers Monthly newsletter
Resources
Documentation
Contact phoenixNAP
Get in touch with us if you have questions or need help with Bare Metal Cloud.