pnap_rancher_api
RancherApi - the Ruby gem for the Rancher Solution API
Simplify enterprise-grade Kubernetes cluster operations and management with Rancher on Bare Metal Cloud.
Deploy Kubernetes clusters using a few API calls.
Knowledge base articles to help you can be found
here
All URLs are relative to (https://api.phoenixnap.com/solutions/rancher/v1beta)
This SDK is automatically generated by the OpenAPI Generator project:
- API version: 0.1 For more information, please visit https://phoenixnap.com/
Installation
Build a gem
To build the Ruby code into a gem:
gem build pnap_rancher_api.gemspec
Then either install the gem locally, replacing <VERSION>
with the actual version:
gem install ./pnap_rancher_api-<VERSION>.gem
(for development, run gem install --dev ./pnap_rancher_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_rancher_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_rancher_api', git: 'https://github.com/phoenixnap/ruby-sdk-bmc-poc', glob: 'RancherApi/*.gemspec'
If you'd like the development version:
gem 'pnap_rancher_api', git: 'https://github.com/phoenixnap/ruby-sdk-bmc-poc', glob: 'RancherApi/*.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_rancher_api'
# Setup authorization
RancherApi.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 = RancherApi::ClustersApi.new
begin
#Cluster list.
result = api_instance.clusters_get
p result
rescue RancherApi::ApiError => e
puts "Exception when calling ClustersApi->clusters_get: #{e}"
end
Authorization can also be setup by using the oauth
library:
# Load the gem
require 'pnap_rancher_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
RancherApi.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/solutions/rancher/v1beta
Class | Method | HTTP request | Description |
---|---|---|---|
RancherApi::ClustersApi | clusters_get | GET /clusters | Cluster list. |
RancherApi::ClustersApi | clusters_id_delete | DELETE /clusters/id | Delete a cluster. |
RancherApi::ClustersApi | clusters_id_get | GET /clusters/id | Retrieve a Cluster |
RancherApi::ClustersApi | clusters_post | POST /clusters | Create a Rancher Server Deployment. |
Documentation for Models
- RancherApi::Cluster
- RancherApi::DeleteResult
- RancherApi::Error
- RancherApi::Node
- RancherApi::NodePool
- RancherApi::RancherClusterCertificates
- RancherApi::RancherClusterConfig
- RancherApi::RancherServerMetadata
- RancherApi::SshConfig
- RancherApi::WorkloadClusterConfig
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.