Rancher API Client

Client for interacting with the Rancher API

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.github.kod4n
ArtifactId

ArtifactId

rancher-client
Last Version

Last Version

1.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

Rancher API Client
Client for interacting with the Rancher API
Project URL

Project URL

https://github.com/kod4n/rancher-client
Source Code Management

Source Code Management

https://github.com/kod4n/rancher-client

Download rancher-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.kod4n/rancher-client/ -->
<dependency>
    <groupId>com.github.kod4n</groupId>
    <artifactId>rancher-client</artifactId>
    <version>1.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.kod4n/rancher-client/
implementation 'com.github.kod4n:rancher-client:1.0.5'
// https://jarcasting.com/artifacts/com.github.kod4n/rancher-client/
implementation ("com.github.kod4n:rancher-client:1.0.5")
'com.github.kod4n:rancher-client:jar:1.0.5'
<dependency org="com.github.kod4n" name="rancher-client" rev="1.0.5">
  <artifact name="rancher-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.kod4n', module='rancher-client', version='1.0.5')
)
libraryDependencies += "com.github.kod4n" % "rancher-client" % "1.0.5"
[com.github.kod4n/rancher-client "1.0.5"]

Dependencies

compile (6)

Group / Artifact Type Version
org.codehaus.groovy : groovy-all jar 2.4.9
com.squareup.retrofit2 : retrofit jar 2.3.0
com.squareup.retrofit2 : converter-jackson jar 2.3.0
org.slf4j : slf4j-api jar 1.7.25
ch.qos.logback : logback-classic jar 1.2.3
org.antlr : ST4 jar 4.0.8

test (3)

Group / Artifact Type Version
org.hamcrest : hamcrest-all jar 1.3
org.testcontainers : spock jar 1.7.2
org.spockframework : spock-core jar 1.1-groovy-2.4

Project Modules

There are no modules declared in this project.

Rancher Groovy SDK

This project is an auto-generated Groovy client for Rancher

This project uses Golang templates and a Rancher API schema file to generate models and services. It was originally derived from the Go-Rancher library.

APIs for this project are accessed using Square's Retrofit2 library.

Client Configuration

The entrypoint for this library is the io.rancher.Rancher class. To configure this client, API secret and access keys need to be generated for your user in a Rancher installation.

The io.rancher.Rancher client is initialized with and io.rancher.Rancher.Config configuration object

def config = new Rancher.Config(
  new URL('https://rancher.mydomain.com'), 
  'MyAPIAccessKey', 
  'MyAPISecretKey'
)
def rancher = new Rancher(config)

From here, you can create an API service and perform operations on a resource.

import io.rancher.service.ServiceApi

def services = rancher.type ServiceApi
def projectServices = service.list('my-project-id').execute()

This library also offers a helper method (extractBody) for getting the body on a Call<T> instance. Here is an example of the usage:

def stacks = rancher.type StackApi
def myStack = extractBody stacks.findById('my-project', 'my-stack')

myStack.id // extractBody gives us direct access to the value returned form the API call

Updating the Rancher API

The API models and services for this projects are generated using the schema for a given Rancher version. To update the API for a rancher version, execute the below steps:

  1. cd generator
  2. Run a Rancher server container using docker run -d --name rancher-server -p 8080:8080 rancher/enterprise:<rancher-version> and wait for the API to become available.
  3. curl -o schemas.json http://localhost:8080/v2-beta/projecst/1a5/schemas
  4. make && ./generator

Versions

Version
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0