pnap_bmc_api

BmcApi - the Ruby gem for the Bare Metal Cloud API

Create, power off, power on, reset, reboot, or shut down your server with the Bare Metal Cloud API. Deprovision servers, get or edit SSH key details, assign public IPs, assign servers to networks and a lot more. Manage your infrastructure more efficiently using just a few simple API calls.

Knowledge base articles to help you can be found here

All URLs are relative to (https://api.phoenixnap.com/bmc/v1/)

This SDK is automatically generated by the OpenAPI Generator project:

Installation

Build a gem

To build the Ruby code into a gem:

gem build pnap_bmc_api.gemspec

Then either install the gem locally, replacing <VERSION> with the actual version:

gem install ./pnap_bmc_api-<VERSION>.gem

(for development, run gem install --dev ./pnap_bmc_api-<VERSION>.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'pnap_bmc_api', '~> <VERSION>'

Install from Git

To install this Gem from this repository, you'll need to get Bundler by doing gem install bundler. Add the following line in your Gemfile:

gem 'pnap_bmc_api', git: 'https://github.com/phoenixnap/ruby-sdk-bmc-poc', glob: 'BmcApi/*.gemspec'

If you'd like the development version:

gem 'pnap_bmc_api', git: 'https://github.com/phoenixnap/ruby-sdk-bmc-poc', glob: 'BmcApi/*.gemspec', branch: 'develop'

Then run bundle install.

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'pnap_bmc_api'

# Setup authorization
BmcApi.configure do |config|
  # Configure OAuth2 access token for authorization: OAuth2
  config.access_token = 'YOUR ACCESS TOKEN'
  # Configure a proc to get access tokens in lieu of the static access_token configuration
  config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' } 
end

api_instance = BmcApi::QuotasApi.new

begin
  #List quotas
  result = api_instance.quotas_get
  p result
rescue BmcApi::ApiError => e
  puts "Exception when calling QuotasApi->quotas_get: #{e}"
end

Authorization can also be setup by using the oauth library:

# Load the gem
require 'pnap_bmc_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
BmcApi.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

Documentation for API Endpoints

All URIs are relative to https://api.phoenixnap.com/bmc/v1

Class Method HTTP request Description
BmcApi::QuotasApi quotas_get GET /quotas List quotas
BmcApi::QuotasApi quotas_quota_id_actions_request_edit_post POST /quotas/quotaId/actions/request-edit Request quota limit change.
BmcApi::QuotasApi quotas_quota_id_get GET /quotas/quotaId Get a quota.
BmcApi::SSHKeysApi ssh_keys_get GET /ssh-keys List SSH Keys.
BmcApi::SSHKeysApi ssh_keys_post POST /ssh-keys Create SSH Key.
BmcApi::SSHKeysApi ssh_keys_ssh_key_id_delete DELETE /ssh-keys/sshKeyId Delete SSH Key.
BmcApi::SSHKeysApi ssh_keys_ssh_key_id_get GET /ssh-keys/sshKeyId Get SSH Key.
BmcApi::SSHKeysApi ssh_keys_ssh_key_id_put PUT /ssh-keys/sshKeyId Edit SSH Key.
BmcApi::ServersApi delete_private_network DELETE /servers/serverId/network-configuration/private-network-configuration/private-networks/privateNetworkId Removes the server from private network.
BmcApi::ServersApi servers_get GET /servers List servers.
BmcApi::ServersApi servers_post POST /servers Create new server.
BmcApi::ServersApi servers_server_id_actions_deprovision_post POST /servers/serverId/actions/deprovision Deprovision a server.
BmcApi::ServersApi servers_server_id_actions_power_off_post POST /servers/serverId/actions/power-off Power off server.
BmcApi::ServersApi servers_server_id_actions_power_on_post POST /servers/serverId/actions/power-on Power on server.
BmcApi::ServersApi servers_server_id_actions_provision_post POST /servers/serverId/actions/provision Provision server.
BmcApi::ServersApi servers_server_id_actions_reboot_post POST /servers/serverId/actions/reboot Reboot server.
BmcApi::ServersApi servers_server_id_actions_reserve_post POST /servers/serverId/actions/reserve Reserve server.
BmcApi::ServersApi servers_server_id_actions_reset_post POST /servers/serverId/actions/reset Reset server.
BmcApi::ServersApi servers_server_id_actions_shutdown_post POST /servers/serverId/actions/shutdown Shutdown server.
BmcApi::ServersApi servers_server_id_delete DELETE /servers/serverId Delete server.
BmcApi::ServersApi servers_server_id_get GET /servers/serverId Get server.
BmcApi::ServersApi servers_server_id_ip_blocks_ip_block_id_delete DELETE /servers/serverId/network-configuration/ip-block-configurations/ip-blocks/ipBlockId Unassign IP Block from Server.
BmcApi::ServersApi servers_server_id_ip_blocks_post POST /servers/serverId/network-configuration/ip-block-configurations/ip-blocks Assign IP Block to Server.
BmcApi::ServersApi servers_server_id_patch PATCH /servers/serverId Patch a Server.
BmcApi::ServersApi servers_server_id_private_networks_patch PATCH /servers/serverId/network-configuration/private-network-configuration/private-networks/privateNetworkId Updates the server's private network's IP addresses
BmcApi::ServersApi servers_server_id_private_networks_post POST /servers/serverId/network-configuration/private-network-configuration/private-networks Adds the server to a private network.
BmcApi::ServersApi servers_server_id_public_networks_delete DELETE /servers/serverId/network-configuration/public-network-configuration/public-networks/publicNetworkId Removes the server from the Public Network
BmcApi::ServersApi servers_server_id_public_networks_patch PATCH /servers/serverId/network-configuration/public-network-configuration/public-networks/publicNetworkId Updates the server's public network's IP addresses.
BmcApi::ServersApi servers_server_id_public_networks_post POST /servers/serverId/network-configuration/public-network-configuration/public-networks Adds the server to a Public Network.
BmcApi::ServersApi servers_server_id_tags_put PUT /servers/serverId/tags Overwrite tags assigned for Server.

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

OAuth2

  • Type: OAuth
  • Flow: application
  • Authorization URL:
  • Scopes:
    • bmc: Grants full access to bmc-api.
    • bmc.read: Grants read only access to bmc-api.