Skip to content

phoenixnap/ruby-sdk-bmc

Repository files navigation


phoenixnap Bare Metal Cloud
Ruby SDK for Bare Metal Cloud

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 CloudDevelopers PortalKnowledge BaseSupport

Requirements

Creating a Bare Metal Cloud account

  1. Go to the Bare Metal Cloud signup page.
  2. Follow the prompts to set up your account.
  3. 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:

  1. Log in to the Bare Metal Cloud portal.
  2. On the left side menu, click on API Credentials.
  3. Click the Create Credentials button.
  4. Fill in the Name and Description fields, select the permissions scope and click Create.
  5. In the table, click on Actions and select View Credentials from the dropdown.
  6. 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:

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.

Resources

Documentation

Contact phoenixNAP

Get in touch with us if you have questions or need help with Bare Metal Cloud.

TwitterFacebookLinkedInInstagramYouTubeEmail


phoenixnap Bare Metal Cloud