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 可以获取具体的项目消费概要。

相关内容

热门资讯

大神推荐!赣湘互娱挂,福建兄弟... 大神推荐!赣湘互娱挂,福建兄弟13水破解器,详细插件(有挂猫腻);暗藏猫腻,小编详细说明福建兄弟13...
每日必备!天天微友有辅助吗,微... 每日必备!天天微友有辅助吗,微信闲来神器软件下载,详细器(存在有挂)1)微信闲来神器软件下载免费钻石...
盘点一款!天酷辅助器,来来云南... 盘点一款!天酷辅助器,来来云南辅助,详细挂(果真有挂)1、实时来来云南辅助透视辅助更新:用户可以随时...
揭秘一下!广西友乐解码器,斗棋... 揭秘一下!广西友乐解码器,斗棋崇阳麻将辅助脚本,详细软件(有挂秘籍)1、每一步都需要思考,不同水平的...
安装程序教程!欢乐达人暗堡破解... 安装程序教程!欢乐达人暗堡破解,赣牌圈控制牌型,详细技巧(有挂规律)亲,关键说明,欢乐达人暗堡破解透...
实操分享!微乐小程序授权,蜀山... 实操分享!微乐小程序授权,蜀山四川免费辅助器,详细app(有挂方法)所有人都在同一条线上,像星星一样...
终于懂了!腾威互娱 辅助工具,... 终于懂了!腾威互娱 辅助工具,九天大厅挂价格,详细方法(有挂技术)1、打开软件启动之后找到中间准星的...
分享一款!欢乐达人破解器,拱趴... 分享一款!欢乐达人破解器,拱趴大菠萝辅助工具,详细攻略(有挂猫腻)1、起透看视 拱趴大菠萝辅助工具辅...
总算了解!欢聚水鱼辅助视频,唯... 总算了解!欢聚水鱼辅助视频,唯思竞技游戏辅助,详细插件(有挂详情)1、游戏颠覆性的策略玩法,独创攻略...
科技通报!0759湛江吴川三脚... 科技通报!0759湛江吴川三脚鸡辅助,0759湛江吴川三脚鸡辅助,详细工具(真实有挂)1、用户打开应...