pnap_tag_api
TagApi - the Ruby gem for the Tags API
Tags are case-sensitive key-value pairs that simplify resource management. The Tag Manager API allows you to create
and manage such tags to later assign them to related resources in your Bare Metal Cloud (through the respective
resource apis) in order to group and categorize them.
Knowledge base articles to help you can be found
here
All URLs are relative to (https://api.phoenixnap.com/tag-manager/v1/)
This SDK is automatically generated by the OpenAPI Generator project:
- API version: 1.0 For more information, please visit https://phoenixnap.com/
Installation
Build a gem
To build the Ruby code into a gem:
gem build pnap_tag_api.gemspec
Then either install the gem locally, replacing <VERSION>
with the actual version:
gem install ./pnap_tag_api-<VERSION>.gem
(for development, run gem install --dev ./pnap_tag_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_tag_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_tag_api', git: 'https://github.com/phoenixnap/ruby-sdk-bmc-poc', glob: 'TagApi/*.gemspec'
If you'd like the development version:
gem 'pnap_tag_api', git: 'https://github.com/phoenixnap/ruby-sdk-bmc-poc', glob: 'TagApi/*.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_tag_api'
# Setup authorization
TagApi.configure do |config|
# Configure OAuth2 access token for authorization: OAuth2
config.access_token = 'YOUR ACCESS TOKEN'
end
api_instance = TagApi::TagsApi.new
opts = {
name: 'env' # String | Query a tag by its name.
}
begin
#List tags.
result = api_instance.(opts)
p result
rescue TagApi::ApiError => e
puts "Exception when calling TagsApi->tags_get: #{e}"
end
Authorization can also be setup by using the oauth
library:
# Load the gem
require 'pnap_tag_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
TagApi.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/tag-manager/v1
Class | Method | HTTP request | Description |
---|---|---|---|
TagApi::TagsApi | tags_get | GET /tags | List tags. |
TagApi::TagsApi | tags_post | POST /tags | Create a Tag. |
TagApi::TagsApi | tags_tag_id_delete | DELETE /tags/tagId | Delete a Tag. |
TagApi::TagsApi | tags_tag_id_get | GET /tags/tagId | Get a Tag. |
TagApi::TagsApi | tags_tag_id_patch | PATCH /tags/tagId | Modify a Tag. |
Documentation for Models
- TagApi::DeleteResult
- TagApi::Error
- TagApi::ResourceAssignment
- TagApi::Tag
- TagApi::TagCreate
- TagApi::TagUpdate
Documentation for Authorization
OAuth2
- Type: OAuth
- Flow: application
- Authorization URL:
- Scopes:
- tags: Grants full access to tags-api.
- tags.read: Grants read only access to tags-api.