示例#1
0
import os
import json
from apigw.client import ApiGWClient

access_token = os.environ.get('ACCESS_TOKEN')

uuid = uuid.uuid4()
mail_address = "pyagent_" + '{}'.format(uuid) + "@dummy.com"
input_data = [{ 
        "distributorFlag": 0,
        "mail": mail_address,
        "password": "******",
        "portalUse": 1
        }] 

client = ApiGWClient(config_path = "config.json", environment = "production")
iam = client.iam(access_token)

print '[1. iam user crete...]'
response = iam.post('users', input_data)

print(">>>>> HTTP status: {0}".format(response.status_code))
data = response.json()

user_uuid = data['users'][0]['uuid']
user_consumer_key = data['users'][0]['consumerKey']
user_secret_key = data['users'][0]['consumerSecret']

search_user_uuid = "users/" + user_uuid
iam.get(search_user_uuid)
#!/usr/bin/env python
# coding: utf-8

import os
from apigw.client import ApiGWClient

access_token = os.environ.get("ACCESS_TOKEN")
service_name = os.environ.get("SERVICE_NAME")

client = ApiGWClient(config_path = "config.json", environment = "production")
business_process = client.business_process(access_token)
response = business_process.get("contracts", service_name)

print(">>>>> HTTP status: {0}".format(response.status_code))
if response.ok:
    print(">>>>> items count: {0}".format(len(response.json().get('items'))))
#!/usr/bin/env python
# coding: utf-8

import os
from apigw.client import ApiGWClient

consumer_key = os.environ.get("CONSUMER_KEY")
secret_key = os.environ.get("SECRET_KEY")

client = ApiGWClient(config_path = "config.json", environment = "production")
oauth = client.oauth(consumer_key, secret_key)
response = oauth.request_access_token()

print(">>>>> HTTP status: {0}".format(response.status_code))
if response.ok:
    print(">>>>> accessToken: {0}".format(response.json().get('accessToken')))
#!/usr/bin/env python
# coding: utf-8

import os
from datetime import date
from apigw.client import ApiGWClient

access_token = os.environ.get("ACCESS_TOKEN")
target_date = date.today().strftime("%Y%m%d")

client = ApiGWClient(config_path = "config.json", environment = "production")
api_log = client.api_log(access_token)
response = api_log.get(target_date)

print(">>>>> HTTP status: {0}".format(response.status_code))
if response.ok:
    print(">>>>> Records count: {0}".format(len(response.json().get('Records'))))