Giter Club home page Giter Club logo

forge-python-wrapper's Introduction

Forge Python Wrapper

Forge API Client Wrapper for Python

Python 3.7 Python 3.8

PyPI version PyPI - Downloads Build Status Coverage Status

Installing

pip install forge-python-wrapper

Documentation

Coming soon!

Usage Examples

"""
If the following Environment Variables are defined there is no need to explicitly provide them when constructing the ForgeApp:
    For 2-legged context:
        FORGE_HUB_ID
        FORGE_CLIENT_ID
        FORGE_CLIENT_SECRET
    Extras for 3-legged context:
        FORGE_REDIRECT_URI
        FORGE_USERNAME
        FORGE_PASSWORD
"""

# 3-legged context - Needed to work with BIM 360 Team Hubs
app = ForgeApp(
    client_id="<your_app_client_id>",
    client_secret="<your_app_client_secret>",
    three_legged=True,
    redirect_uri="<your_app_redirect_uri>",
    username="<your_autodesk_username>",
    password="<your_autodesk_password>",
)

app.get_hubs()
app.hub_id = app.hubs[0]["id"]

app.get_projects(source="docs")
project = app.find_project("<Project Name>", key="name")
project = app.find_project("<Project Id>", key="id")

project.get_top_folders()
top_folders = project.top_folders

project.project_files.get_contents()
contents = project.project_files.contents

parent_folder_id = pj.project_files.id
project.add_folder(pj.project_files.id, "New Folder Name")


# 2-legged context - Needed for methods that use the BIM 360 API
app = ForgeApp(
    client_id="<your_app_client_id>",
    client_secret="<your_app_client_secret>",
    hub_id="<your_hub_id>",
)

app.get_companies()
company = app.find_company("Company Name")

app.get_users()
admin_user = app.find_user("[email protected]")
normal_user_1 = app.find_user("[email protected]")
normal_user_2 = app.find_user("[email protected]")

app.get_projects(source="all")

new_project = app.add_project("New Project Name")

new_project.update(name="Updated Project Name", status="active")

new_project.get_roles()
roles = new_project.roles
role_id = roles[0]["id"]

new_project.x_user_id = admin_user["uid"]
new_project.add_users([admin_user], access_level="admin")
new_project.add_users([normal_user_1, normal_user_2], access_level="user", role_id=role_id)

new_role_id = roles[1]["id"]
new_project.update_user(normal_user_1, company_id=company["id"], role_id=new_role_id)

License

MIT

forge-python-wrapper's People

Contributors

lfparis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

forge-python-wrapper's Issues

Can't get the module to work

Hi There,
Your module looks impressive!

However so I can't get it to work. Trying to connect 2 legged I get the below error.
I'm not sure what the callback url should be.....http://localhost:8080 ??
Here's what I'm trying:
from forge import ForgeApp # noqa:E402

2-legged context - Needed for methods that use the BIM 360 API

app = ForgeApp(
client_id="b.zzzzzzzzzzz",
client_secret="yyyyyyyyyyy",
hub_id="cf5307ae-78a7-435e-b77c-cef643b38e67",
)

app.get_users()
admin_user = app.find_user("[email protected]")
normal_user_1 = app.find_user("[email protected]")
normal_user_2 = app.find_user("[email protected]")

#############################################################################
C:\python>python get_project.py
Traceback (most recent call last):
File "C:\python\get_project.py", line 20, in
app.get_hubs()
^^^
NameError: name 'app' is not defined

C:\python>python get_project.py
2024-04-04 16:11:58 (UTC/GMT +0200) (forge.auth): INFO - Authorized Forge App
Traceback (most recent call last):
File "C:\python\get_project.py", line 27, in
app = ForgeApp(
^^^^^^^^^
File "C:\Users\rolan\AppData\Local\Programs\Python\Python312\Lib\site-packages\forge\forge.py", line 65, in init
self.hub_id = hub_id or os.environ.get("FORGE_HUB_ID")
^^^^^^^^^^^
File "C:\Users\rolan\AppData\Local\Programs\Python\Python312\Lib\site-packages\forge\forge.py", line 86, in hub_id
self._set_hub_id(val)
File "C:\Users\rolan\AppData\Local\Programs\Python\Python312\Lib\site-packages\forge\base.py", line 256, in _set_hub_id
raise ValueError("Invalid Hub ID")
ValueError: Invalid Hub ID

C:\python>python get_project.py
Traceback (most recent call last):
File "C:\Users\rolan\AppData\Local\Programs\Python\Python312\Lib\site-packages\forge\auth.py", line 214, in _set_auth_header
self.token_type, self.access_token
^^^^^^^^^^^^^^^
AttributeError: 'ForgeAuth' object has no attribute 'token_type'

During handling of the above exception, another exception occurred:
#############################################################################

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.