@@ -22,7 +22,7 @@ Instantiate and use the client with the following:
22
22
``` python
23
23
from truefoundry_sdk import TrueFoundry
24
24
client = TrueFoundry(api_key = " YOUR_API_KEY" , base_url = " https://yourhost.com/path/to/api" , )
25
- client.v1. users.invite_user(accept_invite_client_url = ' <control plane url>/invite-accept' , email = ' email' , )
25
+ client.users.invite_user(accept_invite_client_url = ' <control plane url>/invite-accept' , email = ' email' , )
26
26
```
27
27
28
28
## Async Client
@@ -34,8 +34,9 @@ from truefoundry_sdk import AsyncTrueFoundry
34
34
import asyncio
35
35
client = AsyncTrueFoundry(api_key = " YOUR_API_KEY" , base_url = " https://yourhost.com/path/to/api" , )
36
36
async def main () -> None :
37
- await client.v1.users.invite_user(accept_invite_client_url = ' <control plane url>/invite-accept' , email = ' email' , )
38
- asyncio.run(main())```
37
+ await client.users.invite_user(accept_invite_client_url = ' <control plane url>/invite-accept' , email = ' email' , )
38
+ asyncio.run(main())
39
+ ```
39
40
40
41
## Exception Handling
41
42
@@ -45,7 +46,7 @@ will be thrown.
45
46
``` python
46
47
from truefoundry_sdk.core.api_error import ApiError
47
48
try :
48
- client.v1. users.invite_user(... )
49
+ client.users.invite_user(... )
49
50
except ApiError as e:
50
51
print (e.status_code)
51
52
print (e.body)
@@ -58,7 +59,7 @@ Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used
58
59
``` python
59
60
from truefoundry_sdk import TrueFoundry
60
61
client = TrueFoundry(api_key = " YOUR_API_KEY" , base_url = " https://yourhost.com/path/to/api" , )
61
- response = client.v1. users.list(limit = 10 , offset = 0 , )
62
+ response = client.users.list(limit = 10 , offset = 0 , )
62
63
for item in response:
63
64
yield item
64
65
# alternatively, you can paginate page-by-page
@@ -76,14 +77,15 @@ The `.with_raw_response` property returns a "raw" client that can be used to acc
76
77
``` python
77
78
from truefoundry_sdk import TrueFoundry
78
79
client = TrueFoundry(... , )
79
- response = client.v1. users.with_raw_response.invite_user(... )
80
+ response = client.users.with_raw_response.invite_user(... )
80
81
print (response.headers) # access the response headers
81
82
print (response.data) # access the underlying object
82
- response = client.v1. users.with_raw_response .list(... )
83
- print (response.headers) # access the response headers
84
- for item in response.data :
83
+ pager = client.users.list(... )
84
+ print (pager. response.headers) # access the response headers for the first page
85
+ for item in pager :
85
86
print (item) # access the underlying object(s)
86
- for page in response.data.iter_pages():
87
+ for page in pager.iter_pages():
88
+ print (page.response.headers) # access the response headers for each page
87
89
for item in page:
88
90
print (item) # access the underlying object(s)
89
91
```
@@ -103,7 +105,7 @@ A request is deemed retryable when any of the following HTTP status codes is ret
103
105
Use the ` max_retries ` request option to configure this behavior.
104
106
105
107
``` python
106
- client.v1. users.invite_user(... , request_options = {
108
+ client.users.invite_user(... , request_options = {
107
109
" max_retries" : 1
108
110
})
109
111
```
@@ -118,7 +120,7 @@ from truefoundry_sdk import TrueFoundry
118
120
client = TrueFoundry(... , timeout = 20.0 , )
119
121
120
122
# Override timeout for a specific method
121
- client.v1. users.invite_user(... , request_options = {
123
+ client.users.invite_user(... , request_options = {
122
124
" timeout_in_seconds" : 1
123
125
})
124
126
```
0 commit comments