AutodeskForgeAPIforCloudCreditConsumptionSummary
创始人
2024-11-12 10:00:09
0次

Autodesk Forge API 云消费 Credit 汇总。

以下是一个使用 Forge API 拉取云消费 Credit 汇总信息的示例 Python 代码:

import requests
from requests.auth import HTTPBasicAuth
import json
import os

client_id = os.environ['FORGE_CLIENT_ID']
client_secret = os.environ['FORGE_CLIENT_SECRET']
url = 'https://developer.api.autodesk.com/authentication/v1/authenticate'
data = {'client_id': client_id, 'client_secret': client_secret, 'grant_type': 'client_credentials', 'scope': 'data:read'}
response = requests.post(url=url, data=data)
token = response.json()['access_token']
headers = {'Authorization': 'Bearer ' + token}

# Fetch list of Hubs
url = 'https://developer.api.autodesk.com/project/v1/hubs'
response = requests.get(url=url, headers=headers)
hubs = response.json()

# Pick the first hub
hub_id = hubs['data'][0]['id']

# Fetch list of projects in the hub
url = 'https://developer.api.autodesk.com/project/v1/hubs/' + hub_id + '/projects'
response = requests.get(url=url, headers=headers)
projects = response.json()

# Pick the first project
project_id = projects['data'][0]['id']

# Get the consumption data for the project
url = 'https://developer.api.autodesk.com/consumption/v1/organizations/-/projects/' + project_id + '/usage'
response = requests.get(url=url, headers=headers)
consumption_data = response.json()
print(json.dumps(consumption_data, indent=4))

这段代码可以拉取账户中所有项目的消费概要。根据需要修改项目 ID 可以获取具体的项目消费概要。

相关内容

热门资讯

WPK工具手册!AApoker... WPK工具手册!AApoker使用,菠萝智星德州ai多功能透视方法进入游戏-大厅左侧-新手福利-激活...
WPK德州局指南!fishpo... WPK德州局指南!fishpoker透视,AApokerai多功能辅助工具fishpoker透视透视...
WPK透视版绝活儿!哈糖大菠萝... WPK透视版绝活儿!哈糖大菠萝有挂吗,菠萝智星德州ai多功能辅助插件1、玩家可以在哈糖大菠萝有挂吗透...
WPK插件策略!扑克之星辅助,... WPK插件策略!扑克之星辅助,红龙扑克ai多功能辅助器技巧扑克之星辅助透视方法中分为三种模型:扑克之...
WPK软件手册!AApoker... WPK软件手册!AApoker拿好牌,红龙扑克ai多功能辅助器教程1、金币登录送、破产送、升级送、活...
WPK安卓资料!佛手在线大菠萝... WPK安卓资料!佛手在线大菠萝技巧,智星菠萝德州ai多功能透视挂app1、每一步都需要思考,不同水平...
WPK四人项目!德普之星的辅助... WPK四人项目!德普之星的辅助工具介绍,AApokerai多功能透视神器德普之星的辅助工具介绍辅助器...
WPK四人策略!wpk德州局透... WPK四人策略!wpk德州局透视,wpkai多功能辅助插件1、完成wpk德州局透视辅助器v3.3的残...
WPK官网模板!AApoker... WPK官网模板!AApoker插件,WePoKerai多功能透视挂app1、实时AApoker插件透...
WPK官网法子!aapoker... WPK官网法子!aapoker透视脚本,红龙PoKerai多功能透视插件1、下载好aapoker透视...