Пример #1
0
print '[4. iam attach group to role...]'
attach_group_to_role_path = "groups/" + group_uuid + "/roles/" + role_uuid
print attach_group_to_role_path
response = iam.put(attach_group_to_role_path)
iam.get(search_group_uuid)

print '[5. iam attach group to user...]'
attach_group_to_user_path = "groups/" + group_uuid + "/users/" + user_uuid
print attach_group_to_user_path
response = iam.put(attach_group_to_user_path)
search_group_users = "groups/" + group_uuid + "/users"
iam.get(search_group_users)

print '[6. test iam user request APIs]'
client = ApiGWClient(config_path = "config.json", environment = "production")
iam_oauth = client.oauth(user_consumer_key, user_secret_key)
response = iam_oauth.request_access_token()
data = response.json()
iam_access_token = data["accessToken"]

print '[6-1. get IAM API...]'
iam_user_iam = client.iam(iam_access_token)
iam_user_iam.get("users")

print '[6-2. get business-process API...]'
service_name = 'bocn'
business_process = client.business_process(iam_access_token)
business_process.get("contracts", service_name)

print '[7. delete role from group...]'
delete_role_from_group_path = "groups/" + group_uuid  + "/roles/" + role_uuid
#!/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')))