alibaba/acm-sdk-python

Name: acm-sdk-python

Owner: Alibaba

Description: Alibaba ACM SDK for Python

Created: 2018-02-01 14:36:59.0

Updated: 2018-05-17 08:17:30.0

Pushed: 2018-04-08 12:40:13.0

Homepage: null

Size: 94

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

User Guide

Pypi Version License

Introduction

Python SDK for ACM.

Features
  1. Get/Publish/Remove config from ACM server use REST API.
  2. Watch config changes from server.
  3. Auto failover on server failure.
  4. TLS supported.
  5. Address server supported.
  6. Both Alibaba Cloud ACM and Stand-alone deployment supported.
Supported Python?
  1. Python 2.6
  2. Python 2.7
  3. Python 3.3
  4. Python 3.4
  5. Python 3.5
  6. Python 3.6
Supported ACM version
  1. ACM 1.0
Change Logs
Installation

For Python 2.7 and above:

install acm-sdk-python

For Python 2.6:

stall setuptools first:
 https://pypi.io/packages/source/s/setuptools/setuptools-33.1.1.zip
p setuptools-33.1.1.zip
etuptools-33.1.1 && sudo python setup.py install

 setuptools already exists:
 easy_install acm-sdk-python
Getting Started
rt acm

OINT = "acm.aliyun.com:8080"
SPACE = "**********"
 "**********"
 "**********"

t config
nt = acm.ACMClient(ENDPOINT, NAMESPACE, AK, SK)
_id = "com.alibaba.cloud.acm:sample-app.properties"
p = "group"
t(client.get(data_id, group))

d watch
rt time
nt.add_watcher(data_id, group, lambda x:print("config change detected: " + x))
.sleep(5) # wait for config changes
Configuration
nt = ACMClient(endpoint, namespace, ak, sk)
Extra Options

Extra option can be set by set_options, as following:

nt.set_options({key}={value})

Configurable options are:

API Reference
Get Config

ACMClient.get(data_id, group, timeout, no_snapshot)

Add Watchers

ACMClient.add_watchers(data_id, group, cb_list)

Add watchers to a specified config item.

Remove Watcher

ACMClient.remove_watcher(data_id, group, cb, remove_all)

Remove watcher from specified key.

List All Config

ACMClient.list_all(group, prefix)

Get all config items of current namespace, with dataId and group information only.

Publish Config

ACMClient.publish(data_id, group, content, timeout)

Publish one data item to ACM.

Remove Config

ACMClient.remove_watcher(data_id, group, cb, remove_all)

Remove one data item from ACM.

Debugging Mode

Debugging mode if useful for getting more detailed log on console.

Debugging mode can be set by:

lient.set_debugging()
ly effective within the current process
CLI Tool

A CLI Tool is along with python SDK to make convenient access and management of config items in ACM server.

You can use acm {subcommand} directly after installation, sub commands available are as following:

add                 add a namespace
use                 switch to a namespace
current             show current endpoint and namespace
show                show all endpoints and namespaces
list                get list of dataIds
pull                get one config content
push                push one config
export              export dataIds to local files
import              import files to ACM server

Use acm -h to see the detailed manual.

Data Security Options

ACM allows you to encrypt data along with Key Management Service, service provided by Alibaba Cloud (also known as KMS).

To use this feature, you can follow these steps:

  1. Install KMS SDK by pip install aliyun-python-sdk-kms.
  2. Name your data_id with a cipher- prefix.
  3. Get and filling all the needed configuration to ACMClient, info needed are: region_id, kms_ak, kms_secret, key_id.
  4. Just make API calls and SDK will process data encrypt & decrypt automatically.

Example:

acm.ACMClient(ENDPOINT, NAMESPACE, AK, SK)
t_options(kms_enabled=True, kms_ak=KMS_AK, kms_secret=KMS_SECRET, region_id=REGION_ID, key_id=KEY_ID)

blish an encrypted config item.
blish("cipher-dataId", None, "plainText")

t the content of an encrypted config item.
t("cipher-dataId", None)
Other Resources

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.