Skip to content

Overview

Welcome to the py-client wiki!

Usage

The basic usage of the client is to create a client object, and then call methods on it. For example:

duploctl <service> <action> <parameters>

Configuration

Global Settings

The DuploCloud python client will reference these environment variables:

Variable Arg Description
DUPLO_HOST --host DuploCloud hostname
DUPLO_TOKEN --token DuploCloud access token
DUPLO_TENANT --tenant DuploCloud tenant name if you don't have the id
DUPLO_TENANT_ID --tenant-id If you have the id of the DuploCloud tenant instead of the name
DUPLO_HOME --home-dir DuploCloud home directory
DUPLO_CACHE --cache-dir DuploCloud cache directory
DUPLO_CONFIG --config-file DuploCloud config file
DUPLO_CONTEXT --context DuploCloud context to use from configuration file.
DUPLO_BROWSER --browser Desired browser to use.

Configuration File

The configuration file contains all the settings and a list of contexts to choose from. This where any user specific settings are stored. The default location is ~/.duplo/config. See the global settings above for the environment variable to change the location. On any command you may choose a context from the configuration file using the --context option. Choosing a context will take precedence over the environment variables. The current-context is only used if no host or context is provided by environment variables or command line options.

current-context: myportal
config:
  browser: firefox
contexts:
- name: myportal
  host: https://myportal.duplocloud.net
  token: abc123
- name: interactive-admin
  host: https://myportal.duplocloud.net
  interactive: true
  admin: true

Interactive Mode

The interactive mode will use the browser to authenticate and get a token. This is useful for when you don't have a token or want to use a different account. The interactive mode will also allow you to choose a tenant if you have access to more than one. You can also choose to use the admin token if you have access to it with --admin option.

duploctl service list --interactive --tenant mytenant

Output

Select Python Formatter for output

default: json

duploctl service list -o yaml

Query

JMESPath query for filtering and reformatting the response

A few examples:

duploctl lambda list -q "[].FunctionName" -o yaml
duploctl lambda list -q "[].[FunctionName, Handler, PackageType.Value]"
duploctl service list -q "[].[Name, Template.Containers[0].Image]"

A more exciting example:

duploctl tenant list -q "[].AccountName" -o yaml --admin --interactive --nocache