rancher2-api-client
TypeScript icon, indicating that this package has built-in type declarations

0.3.2 • Public • Published

Rancher2 API client

Install

npm install rancher2-api-client

Usage

const Rabcher = require('rancher2-api-client');
 
let rancher = new Rabcher('https://localhost:8000/', 'user', 'password');
 
rancher.projects.list().then( (projects_list) => {
    console.log(projects_list);
}).catch( (error) => {
    console.log(error);
});

API

ping() -> boolean

Check rancher server.

clusters.list(filters[object] = {}) -> array[object]

Get list clusters.

clusters.get(name[string]) -> Cluster

Get cluster object.

projects.list(filters[object] = {}) -> array[object]

Get list projects.

projects.get(name[string]) -> Project

Get project object.

projects.exist(name[string]) -> boolean

Get existing project flag.

project.cluster_id -> string

Get cluster id of project.

project.id -> string

Get id of project.

project.info -> object

Get setting of project.

project.workloads.list(filters[object] = {}) -> array[object]

Get list workloads.

project.workloads.get(namespace[string], name[string]) -> Workload

Get existing workload object.

project.workloads.exist(namespace[string], name[string]) -> boolean

Get existing workload flag.

project.workloads.create(namespace[string], name[string], options[object]) -> Workload

Get new workload object.

project.ingresses.list(filters = {}) -> array[object]

Get list ingresses.

project.ingresses.get(name) -> Ingress

Get existing ingress object.

project.ingresses.exist(name) -> boolean

Get existing ingress flag.

project.ingresses.create(namespace, name, options) -> Ingress

Get new ingress object.

workload.cluster_id -> string

Get cluster id of workload.

workload.project_id -> string

Get project id of workload.

workload.namespace_id -> string

Get namespace id of workload.

workload.id -> string

Get id of workload.

workload.info -> object

Get setting of workload.

workload.delete() -> boolean

delete workload.

workload.update(options[object]) -> Workload

update workload.

ingress.cluster_id -> string

Get cluster id of ingress.

ingress.project_id -> string

Get project id of ingress.

ingress.namespace_id -> string

Get namespace id of ingress.

ingress.id -> string

Get id of ingress.

ingress.info -> object

Get setting of ingress.

ingress.update(options[object]) -> Ingress

update ingress.

ingress.delete() -> boolean

delete ingress.

Workload options:

{
    containers: [
        {
            image: "ubuntu:18.04",
            imagePullPolicy: "IfNotPresent",
            entrypoint: [
                "top"
            ],
            securityContext: {
                allowPrivilegeEscalation: false,
                capabilities: { },
                privileged: false,
                procMount: "Default",
                readOnlyRootFilesystem: false,
                runAsNonRoot: false
            },
            stdin: true,
            terminationMessagePath: "/dev/termination-log",
            terminationMessagePolicy: "File",
            tty: true
        }
    ],
    ephemeralContainers: [ ],
    gids: [ ],
    hostAliases: [ ],
    hostIPC: false,
    hostNetwork: false,
    hostPID: false,
    imagePullSecrets: [ ],
    nodeId: "",
    paused: false,
    readinessGates: [ ],
    sysctls: [ ],
    topologySpreadConstraints: [ ],
    volumes: [ ],
    workloadMetrics: [ ]
}

Ingress options:

{
    description: "created by rancher api client",
    rules: [
        {
            host: "tsts.local",
            paths: [
                {
                    path: '/test-path1',
                    targetPort: 3000,
                    workloadIds: ['workloadId']
                },
                {
                    path: '/test-path2',
                    targetPort: 3000,
                    workloadIds: ['workloadId']
                }
            ]
        }
    ],
    tls: []
}

Package Sidebar

Install

npm i rancher2-api-client

Weekly Downloads

2

Version

0.3.2

License

ISC

Unpacked Size

73.7 kB

Total Files

72

Last publish

Collaborators

  • samuray