IpApi - the Ruby gem for the IP Addresses API
Public IP blocks are a set of contiguous IPs that allow you to access your servers or networks from the internet.
Use the IP Addresses API to request and delete IP blocks.
Knowledge base articles to help you can be found
here
All URLs are relative to (https://api.phoenixnap.com/ips/v1/)
This SDK is automatically generated by the OpenAPI Generator project:
- API version: 1.0 For more information, please visit https://phoenixnap.com/
To build the Ruby code into a gem:
gem build pnap_ip_api.gemspec
Then either install the gem locally, replacing <VERSION>
with the actual version:
gem install ./pnap_ip_api-<VERSION>.gem
(for development, run gem install --dev ./pnap_ip_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_ip_api', '~> <VERSION>'
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_ip_api', git: 'https://github.com/phoenixnap/ruby-sdk-bmc-poc', glob: 'IpApi/*.gemspec'
If you'd like the development version:
gem 'pnap_ip_api', git: 'https://github.com/phoenixnap/ruby-sdk-bmc-poc', glob: 'IpApi/*.gemspec', branch: 'develop'
Then run bundle install
.
Include the Ruby code directly using -I
as follows:
ruby -Ilib script.rb
Please follow the installation procedure and then run the following code:
# Load the gem
require 'pnap_ip_api'
# Setup authorization
IpApi.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 = IpApi::IPBlocksApi.new
opts = {
tag: ['inner_example'] # Array<String> | List of tags, in the form tagName.tagValue, to filter by.
}
begin
#List IP Blocks.
result = api_instance.ip_blocks_get(opts)
p result
rescue IpApi::ApiError => e
puts "Exception when calling IPBlocksApi->ip_blocks_get: #{e}"
end
Authorization can also be setup by using the oauth
library:
# Load the gem
require 'pnap_ip_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
IpApi.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
All URIs are relative to https://api.phoenixnap.com/ips/v1
Class | Method | HTTP request | Description |
---|---|---|---|
IpApi::IPBlocksApi | ip_blocks_get | GET /ip-blocks | List IP Blocks. |
IpApi::IPBlocksApi | ip_blocks_ip_block_id_delete | DELETE /ip-blocks/{ipBlockId} | Delete IP Block. |
IpApi::IPBlocksApi | ip_blocks_ip_block_id_get | GET /ip-blocks/{ipBlockId} | Get IP Block. |
IpApi::IPBlocksApi | ip_blocks_ip_block_id_patch | PATCH /ip-blocks/{ipBlockId} | Update IP block. |
IpApi::IPBlocksApi | ip_blocks_ip_block_id_tags_put | PUT /ip-blocks/{ipBlockId}/tags | Overwrite tags assigned for IP Block. |
IpApi::IPBlocksApi | ip_blocks_post | POST /ip-blocks | Create an IP Block. |
- IpApi::DeleteIpBlockResult
- IpApi::Error
- IpApi::IpBlock
- IpApi::IpBlockCreate
- IpApi::IpBlockPatch
- IpApi::TagAssignment
- IpApi::TagAssignmentRequest
Authentication schemes defined for the API:
- Type: OAuth
- Flow: application
- Authorization URL:
- Scopes:
- bmc: Grants full access to bmc-api.
- bmc.read: Grants read only access to bmc-api.