Skip to content

Commit c62de6b

Browse files
update README with usage instructions
1 parent f011c18 commit c62de6b

File tree

1 file changed

+33
-41
lines changed

1 file changed

+33
-41
lines changed

README.md

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -53,47 +53,39 @@ Execute `pytest` to run the tests.
5353
Please follow the [installation procedure](#installation--usage) and then run the following:
5454

5555
```python
56-
57-
import time
58-
import plane
59-
from plane.rest import ApiException
60-
from pprint import pprint
61-
62-
# Defining the host is optional and defaults to https://api.plane.so
63-
# See configuration.py for a list of all supported configuration parameters.
64-
configuration = plane.Configuration(
65-
host = "https://api.plane.so"
66-
)
67-
68-
# The client must configure the authentication and authorization parameters
69-
# in accordance with the API server security policy.
70-
# Examples for each auth method are provided below, use the example that
71-
# satisfies your auth use case.
72-
73-
# Configure API key authorization: ApiKeyAuthentication
74-
configuration.api_key['ApiKeyAuthentication'] = os.environ["API_KEY"]
75-
76-
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
77-
# configuration.api_key_prefix['ApiKeyAuthentication'] = 'Bearer'
78-
79-
configuration.access_token = os.environ["ACCESS_TOKEN"]
80-
81-
configuration.access_token = os.environ["ACCESS_TOKEN"]
82-
83-
84-
# Enter a context with an instance of the API client
85-
with plane.ApiClient(configuration) as api_client:
86-
# Create an instance of the API class
87-
api_instance = plane.AssetsApi(api_client)
88-
slug = 'my-workspace' # str | Workspace slug
89-
generic_asset_upload_request = {"name":"image.jpg","type":"image/jpeg","size":1024000,"project_id":"123e4567-e89b-12d3-a456-426614174000","external_id":"1234567890","external_source":"github"} # GenericAssetUploadRequest |
90-
91-
try:
92-
# Generate presigned URL for generic asset upload
93-
api_instance.create_generic_asset_upload(slug, generic_asset_upload_request)
94-
except ApiException as e:
95-
print("Exception when calling AssetsApi->create_generic_asset_upload: %s\n" % e)
96-
56+
from plane.configuration import Configuration
57+
from plane.api_client import ApiClient
58+
from plane.api.users_api import UsersApi
59+
from plane.api.projects_api import ProjectsApi
60+
from plane.exceptions import ApiException
61+
62+
def test_api():
63+
64+
# Configure API Key authentication
65+
configuration = Configuration(
66+
api_key={'ApiKeyAuthentication': <API_KEY>}
67+
)
68+
69+
# Configure Access Token authentication
70+
# configuration = Configuration(
71+
# access_token='<PLANE_ACCESS_TOKEN>'
72+
# )
73+
74+
# Create API client instance
75+
api_client = ApiClient(configuration)
76+
77+
# Create Users API instance
78+
users_api = UsersApi(api_client)
79+
80+
# Call get_current_user endpoint
81+
print("Fetching current user information...")
82+
user = users_api.get_current_user()
83+
print(user.email)
84+
85+
projects_api = ProjectsApi(api_client)
86+
projects_response = projects_api.list_projects(slug="<workspace_slug>")
87+
for project in projects_response.results:
88+
print(f"{project.id} - {project.name}")
9789
```
9890

9991
## Documentation for API Endpoints

0 commit comments

Comments
 (0)