pierre-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. pierre_sdk-0.1.0/LICENSE +189 -0
  2. pierre_sdk-0.1.0/PKG-INFO +153 -0
  3. pierre_sdk-0.1.0/README.md +130 -0
  4. pierre_sdk-0.1.0/pyproject.toml +92 -0
  5. pierre_sdk-0.1.0/pyproject.toml.orig +92 -0
  6. pierre_sdk-0.1.0/src/pierre/__init__.py +59 -0
  7. pierre_sdk-0.1.0/src/pierre/_client.py +544 -0
  8. pierre_sdk-0.1.0/src/pierre/_compat.py +14 -0
  9. pierre_sdk-0.1.0/src/pierre/_content.py +168 -0
  10. pierre_sdk-0.1.0/src/pierre/_credentials.py +321 -0
  11. pierre_sdk-0.1.0/src/pierre/_errors.py +205 -0
  12. pierre_sdk-0.1.0/src/pierre/_generated/__init__.py +2 -0
  13. pierre_sdk-0.1.0/src/pierre/_generated/client.py +54 -0
  14. pierre_sdk-0.1.0/src/pierre/_generated/headers.py +69 -0
  15. pierre_sdk-0.1.0/src/pierre/_generated/namespaces/__init__.py +2 -0
  16. pierre_sdk-0.1.0/src/pierre/_generated/namespaces/meta.py +121 -0
  17. pierre_sdk-0.1.0/src/pierre/_generated/namespaces/repos.py +5513 -0
  18. pierre_sdk-0.1.0/src/pierre/_generated/schemas.py +1437 -0
  19. pierre_sdk-0.1.0/src/pierre/_generated/scopes.py +12 -0
  20. pierre_sdk-0.1.0/src/pierre/_generated/webhooks.py +30 -0
  21. pierre_sdk-0.1.0/src/pierre/_helpers/__init__.py +1 -0
  22. pierre_sdk-0.1.0/src/pierre/_helpers/commits.py +220 -0
  23. pierre_sdk-0.1.0/src/pierre/_helpers/repos.py +58 -0
  24. pierre_sdk-0.1.0/src/pierre/_operation.py +66 -0
  25. pierre_sdk-0.1.0/src/pierre/_page.py +154 -0
  26. pierre_sdk-0.1.0/src/pierre/_response.py +92 -0
  27. pierre_sdk-0.1.0/src/pierre/_retry.py +65 -0
  28. pierre_sdk-0.1.0/src/pierre/_runtime.py +761 -0
  29. pierre_sdk-0.1.0/src/pierre/_types.py +72 -0
  30. pierre_sdk-0.1.0/src/pierre/_version.py +3 -0
  31. pierre_sdk-0.1.0/src/pierre/auth.py +84 -0
  32. pierre_sdk-0.1.0/src/pierre/git.py +161 -0
  33. pierre_sdk-0.1.0/src/pierre/py.typed +0 -0
  34. pierre_sdk-0.1.0/src/pierre/types.py +14 -0
  35. pierre_sdk-0.1.0/src/pierre/webhooks.py +145 -0
@@ -0,0 +1,189 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the
13
+ copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other
16
+ entities that control, are controlled by, or are under common control with
17
+ that entity. For the purposes of this definition, "control" means (i) the
18
+ power, direct or indirect, to cause the direction or management of such
19
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
20
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of
21
+ such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation source, and
28
+ configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical transformation
31
+ or translation of a Source form, including but not limited to compiled
32
+ object code, generated documentation, and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or Object form,
35
+ made available under the License, as indicated by a copyright notice that is
36
+ included in or attached to the work (an example is provided in the Appendix
37
+ below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object form,
40
+ that is based on (or derived from) the Work and for which the editorial
41
+ revisions, annotations, elaborations, or other modifications represent, as a
42
+ whole, an original work of authorship. For the purposes of this License,
43
+ Derivative Works shall not include works that remain separable from, or
44
+ merely link (or bind by name) to the interfaces of, the Work and Derivative
45
+ Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including the original
48
+ version of the Work and any modifications or additions to that Work or
49
+ Derivative Works thereof, that is intentionally submitted to Licensor for
50
+ inclusion in the Work by the copyright owner or by an individual or Legal
51
+ Entity authorized to submit on behalf of the copyright owner. For the
52
+ purposes of this definition, "submitted" means any form of electronic,
53
+ verbal, or written communication sent to the Licensor or its
54
+ representatives, including but not limited to communication on electronic
55
+ mailing lists, source code control systems, and issue tracking systems that
56
+ are managed by, or on behalf of, the Licensor for the purpose of discussing
57
+ and improving the Work, but excluding communication that is conspicuously
58
+ marked or otherwise designated in writing by the copyright owner as "Not a
59
+ Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
62
+ behalf of whom a Contribution has been received by Licensor and subsequently
63
+ incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
66
+ License, each Contributor hereby grants to You a perpetual, worldwide,
67
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
68
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
69
+ sublicense, and distribute the Work and such Derivative Works in Source or
70
+ Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of this
73
+ License, each Contributor hereby grants to You a perpetual, worldwide,
74
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in
75
+ this section) patent license to make, have made, use, offer to sell, sell,
76
+ import, and otherwise transfer the Work, where such license applies only to
77
+ those patent claims licensable by such Contributor that are necessarily
78
+ infringed by their Contribution(s) alone or by combination of their
79
+ Contribution(s) with the Work to which such Contribution(s) was submitted.
80
+ If You institute patent litigation against any entity (including a
81
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
82
+ Contribution incorporated within the Work constitutes direct or contributory
83
+ patent infringement, then any patent licenses granted to You under this
84
+ License for that Work shall terminate as of the date such litigation is
85
+ filed.
86
+
87
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
88
+ Derivative Works thereof in any medium, with or without modifications, and
89
+ in Source or Object form, provided that You meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative Works a
92
+ copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices stating
95
+ that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works that You
98
+ distribute, all copyright, patent, trademark, and attribution notices from
99
+ the Source form of the Work, excluding those notices that do not pertain to
100
+ any part of the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as part of its distribution,
103
+ then any Derivative Works that You distribute must include a readable copy
104
+ of the attribution notices contained within such NOTICE file, excluding
105
+ those notices that do not pertain to any part of the Derivative Works, in at
106
+ least one of the following places: within a NOTICE text file distributed as
107
+ part of the Derivative Works; within the Source form or documentation, if
108
+ provided along with the Derivative Works; or, within a display generated by
109
+ the Derivative Works, if and wherever such third-party notices normally
110
+ appear. The contents of the NOTICE file are for informational purposes only
111
+ and do not modify the License. You may add Your own attribution notices
112
+ within Derivative Works that You distribute, alongside or as an addendum to
113
+ the NOTICE text from the Work, provided that such additional attribution
114
+ notices cannot be construed as modifying the License.
115
+
116
+ You may add Your own copyright statement to Your modifications and may
117
+ provide additional or different license terms and conditions for use,
118
+ reproduction, or distribution of Your modifications, or for any such
119
+ Derivative Works as a whole, provided Your use, reproduction, and
120
+ distribution of the Work otherwise complies with the conditions stated in
121
+ this License.
122
+
123
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
124
+ Contribution intentionally submitted for inclusion in the Work by You to the
125
+ Licensor shall be under the terms and conditions of this License, without
126
+ any additional terms or conditions. Notwithstanding the above, nothing
127
+ herein shall supersede or modify the terms of any separate license agreement
128
+ you may have executed with Licensor regarding such Contributions.
129
+
130
+ 6. Trademarks. This License does not grant permission to use the trade names,
131
+ trademarks, service marks, or product names of the Licensor, except as
132
+ required for reasonable and customary use in describing the origin of the
133
+ Work and reproducing the content of the NOTICE file.
134
+
135
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
136
+ writing, Licensor provides the Work (and each Contributor provides its
137
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
138
+ KIND, either express or implied, including, without limitation, any
139
+ warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or
140
+ FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining
141
+ the appropriateness of using or redistributing the Work and assume any risks
142
+ associated with Your exercise of permissions under this License.
143
+
144
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
145
+ tort (including negligence), contract, or otherwise, unless required by
146
+ applicable law (such as deliberate and grossly negligent acts) or agreed to
147
+ in writing, shall any Contributor be liable to You for damages, including
148
+ any direct, indirect, special, incidental, or consequential damages of any
149
+ character arising as a result of this License or out of the use or inability
150
+ to use the Work (including but not limited to damages for loss of goodwill,
151
+ work stoppage, computer failure or malfunction, or any and all other
152
+ commercial damages or losses), even if such Contributor has been advised of
153
+ the possibility of such damages.
154
+
155
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
156
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
157
+ acceptance of support, warranty, indemnity, or other liability obligations
158
+ and/or rights consistent with this License. However, in accepting such
159
+ obligations, You may act only on Your own behalf and on Your sole
160
+ responsibility, not on behalf of any other Contributor, and only if You
161
+ agree to indemnify, defend, and hold each Contributor harmless for any
162
+ liability incurred by, or claims asserted against, such Contributor by
163
+ reason of your accepting any such warranty or additional liability.
164
+
165
+ END OF TERMS AND CONDITIONS
166
+
167
+ APPENDIX: How to apply the Apache License to your work.
168
+
169
+ To apply the Apache License to your work, attach the following
170
+ boilerplate notice, with the fields enclosed by brackets "[]"
171
+ replaced with your own identifying information. (Don't include
172
+ the brackets!) The text should be enclosed in the appropriate
173
+ comment syntax for the file format. We also recommend that a
174
+ file or class name and description of purpose be included on the
175
+ same "printed page" as the copyright notice for easier
176
+ identification within third-party archives.
177
+
178
+ Copyright 2026 Pierre Computer Company
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
181
+ this file except in compliance with the License. You may obtain a copy of the
182
+ License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software distributed
187
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
188
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
189
+ specific language governing permissions and limitations under the License.
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.4
2
+ Name: pierre-sdk
3
+ Version: 0.1.0
4
+ Summary: The Pierre SDK for Python
5
+ Author: Pierre
6
+ Author-email: Pierre <support@pierre.co>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Typing :: Typed
17
+ Requires-Dist: cryptography>=41.0.0
18
+ Requires-Dist: httpx>=0.27.0,<1
19
+ Requires-Dist: typing-extensions>=4.5.0 ; python_full_version < '3.11'
20
+ Requires-Python: >=3.10
21
+ Project-URL: Homepage, https://pierre.computer
22
+ Description-Content-Type: text/markdown
23
+
24
+ # Pierre SDK for Python
25
+
26
+ The Python SDK of Pierre: `Pierre` for blocking code, and `AsyncPierre` for `asyncio` code. Both
27
+ clients have the same namespaces, helpers, errors, pagination, and retries as `@pierre/sdk` in
28
+ TypeScript.
29
+
30
+ ## Use the client
31
+
32
+ `Pierre()` reads `PIERRE_ORG` and `PIERRE_PRIVATE_KEY`, or the other variables in
33
+ [Credentials](#credentials). Each method path is the catalog ID of its operation, with each segment
34
+ in snake_case. Each method takes keyword arguments with the wire names of the HTTP API.
35
+
36
+ ```python
37
+ from pierre import Pierre
38
+
39
+ pierre = Pierre()
40
+ pierre.repos.create(repo_name="acme/web", default_branch="main")
41
+ pierre.repos.branches.create(repo_name="acme/web", target_branch="feat", base_ref="main")
42
+ pierre.repos.commits.create(
43
+ repo_name="acme/web",
44
+ target_branch="feat",
45
+ commit_message="Add readme",
46
+ author={"name": "Bot", "email": "bot@acme.dev"},
47
+ files=[{"path": "README.md", "content": "# Web"}],
48
+ )
49
+ for repo in pierre.repos.list(q="web"):
50
+ print(repo["repo_name"])
51
+ ```
52
+
53
+ `AsyncPierre` takes the same arguments, and each method is async:
54
+
55
+ ```python
56
+ from pierre import AsyncPierre
57
+
58
+ pierre = AsyncPierre()
59
+ repo = await pierre.repos.get(repo_name="acme/web")
60
+ async for branch in pierre.repos.branches.list(repo_name="acme/web"):
61
+ print(branch["name"])
62
+ ```
63
+
64
+ A result is a dict with the wire names of the response, typed as a `TypedDict` from `pierre.types`.
65
+ A byte response, such as `repos.files.get`, returns the `httpx.Response`, which the caller reads or
66
+ closes.
67
+
68
+ ## Credentials
69
+
70
+ Give one credential. A credential in the options replaces every credential in the environment.
71
+
72
+ | Option | Variable | Use |
73
+ | ------------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
74
+ | `private_key` | `PIERRE_PRIVATE_KEY`, or the file at `PIERRE_PRIVATE_KEY_FILE` | The SDK signs a 5-minute token for each request, with only the scopes of the operation. |
75
+ | `token` | `PIERRE_TOKEN` | A fixed token. The server checks its scopes. |
76
+ | `get_token` | none | A function that returns a token for each request, for a client with no private key. |
77
+
78
+ With no credential in the options, the SDK uses the first variable that is set: `PIERRE_TOKEN`, then
79
+ `PIERRE_PRIVATE_KEY`, then `PIERRE_PRIVATE_KEY_FILE`.
80
+
81
+ `org` (`PIERRE_ORG`) names the organization. With `token`, the SDK reads it from the `iss` claim.
82
+ `base_url` (`PIERRE_API_BASE_URL`) and `git_host` (`PIERRE_GIT_HOST`) replace the default hosts,
83
+ `https://api.{org}.code.storage` and `{org}.code.storage`. The base URL ends before `/api`, because
84
+ each operation path starts with `/api`: for example `https://api.acme.code.storage`, not
85
+ `https://api.acme.code.storage/api/v1`. A path in front of `/api`, such as the prefix of a proxy,
86
+ stays in the base URL. The Git host is a host name with an optional port and no scheme, for example
87
+ `acme.code.storage`.
88
+
89
+ ## Options
90
+
91
+ The client options are `org`, `private_key`, `token`, `get_token`, `base_url`, `git_host`, `timeout`
92
+ (seconds, default 60), `max_retries` (default 2), `default_headers`, `http_client`, and
93
+ `ref_policies`. `pierre.options` holds the settings with no credential, and `pierre.with_options()`
94
+ returns a copy with changed options.
95
+
96
+ A client keeps one httpx client. `with Pierre() as pierre:` and
97
+ `async with AsyncPierre() as pierre:` close the httpx client that the SDK made at the end of the
98
+ block. An `http_client` that you give stays open.
99
+
100
+ Each method also takes the request options `extra_headers`, `timeout`, `max_retries`,
101
+ `idempotency_key`, and `ref_policies` for one call.
102
+
103
+ `idempotency_key` applies only to an operation that accepts an `Idempotency-Key`. On any other
104
+ operation, the call raises `PierreError` and sends no request.
105
+
106
+ An optional argument has the default `NOT_GIVEN`, which the SDK does not send. `None` sends `null`.
107
+
108
+ ## Responses, pages, and errors
109
+
110
+ - `pierre.with_raw_response` has the namespaces of the client. Each method returns a `RawResponse`
111
+ with `data`, `response` (the `httpx.Response`), `headers` (the declared response headers), and
112
+ `request_id`.
113
+ - A list method returns a `Page` in `Pierre`. In `AsyncPierre`, it returns an `AsyncPaginator`:
114
+ `await` gives the first `AsyncPage`, and `async for` gives every item. A page has `data`,
115
+ `has_more`, `next_cursor`, `body`, `response`, `has_next_page()`, `get_next_page()`, and
116
+ `iter_pages()`. To serialize a page, serialize `page.body`, the response that the API sent.
117
+ - Every error extends `PierreError`. An HTTP error is an `APIError` with `status`, `code`, `title`,
118
+ `detail`, `request_id`, `headers`, `body`, and `doc_url`, with a subclass for each status family,
119
+ and `MergeConflictError` and `RefUpdateError` for codes. `RefUpdateError.result` is a
120
+ `RefUpdateResult`, or a `NotesWriteResult` for a notes write, so `error.result["status"]` gives
121
+ the reason with no cast, for example `conflict`. A failed ref guard, with the code
122
+ `ref_guard_failed`, raises `RefGuardError`, a `ConflictError` with `guard` and `current_sha`: send
123
+ `current_sha` as the guard of the next attempt.
124
+
125
+ ## Local utilities
126
+
127
+ Import the modules of the local utilities before you name a client `pierre`, because the client name
128
+ hides the package:
129
+
130
+ ```python
131
+ from pierre import Pierre, auth, git, webhooks
132
+
133
+ pierre = Pierre()
134
+ token = auth.create_token(pierre, scopes=["git:read"], repo="acme/web")
135
+ url = git.remote_url(pierre, repo_name="acme/web")
136
+ ```
137
+
138
+ - `auth.create_token(client, scopes=[...])` signs a token with no HTTP call. `auth.SCOPES` lists the
139
+ scopes of the API, and `auth.Scope` is their type.
140
+ - `git.remote_url(client, repo_name=...)` builds a Git remote URL with a 15-minute token. With
141
+ `AsyncPierre`, await the result.
142
+ - `webhooks.verify_webhook(payload=..., headers=..., secret=...)` checks a webhook delivery and
143
+ returns the typed event.
144
+
145
+ ## Differences from the TypeScript SDK
146
+
147
+ - A timeout is in seconds, as in `httpx`. It covers each attempt: the token, the upload, the
148
+ response headers, and a JSON body. `Pierre` cannot stop a blocking `get_token`, so the attempt
149
+ fails when the token arrives after the deadline.
150
+ - There is no `signal`. To stop an `AsyncPierre` call, cancel its task.
151
+ - An async method starts its request when the caller awaits it, as a coroutine does.
152
+ - `pierre.with_raw_response` replaces `withResponse()`. The SDK reads the body of a JSON response,
153
+ so there is no `asResponse()`. A byte response stays a stream.
@@ -0,0 +1,130 @@
1
+ # Pierre SDK for Python
2
+
3
+ The Python SDK of Pierre: `Pierre` for blocking code, and `AsyncPierre` for `asyncio` code. Both
4
+ clients have the same namespaces, helpers, errors, pagination, and retries as `@pierre/sdk` in
5
+ TypeScript.
6
+
7
+ ## Use the client
8
+
9
+ `Pierre()` reads `PIERRE_ORG` and `PIERRE_PRIVATE_KEY`, or the other variables in
10
+ [Credentials](#credentials). Each method path is the catalog ID of its operation, with each segment
11
+ in snake_case. Each method takes keyword arguments with the wire names of the HTTP API.
12
+
13
+ ```python
14
+ from pierre import Pierre
15
+
16
+ pierre = Pierre()
17
+ pierre.repos.create(repo_name="acme/web", default_branch="main")
18
+ pierre.repos.branches.create(repo_name="acme/web", target_branch="feat", base_ref="main")
19
+ pierre.repos.commits.create(
20
+ repo_name="acme/web",
21
+ target_branch="feat",
22
+ commit_message="Add readme",
23
+ author={"name": "Bot", "email": "bot@acme.dev"},
24
+ files=[{"path": "README.md", "content": "# Web"}],
25
+ )
26
+ for repo in pierre.repos.list(q="web"):
27
+ print(repo["repo_name"])
28
+ ```
29
+
30
+ `AsyncPierre` takes the same arguments, and each method is async:
31
+
32
+ ```python
33
+ from pierre import AsyncPierre
34
+
35
+ pierre = AsyncPierre()
36
+ repo = await pierre.repos.get(repo_name="acme/web")
37
+ async for branch in pierre.repos.branches.list(repo_name="acme/web"):
38
+ print(branch["name"])
39
+ ```
40
+
41
+ A result is a dict with the wire names of the response, typed as a `TypedDict` from `pierre.types`.
42
+ A byte response, such as `repos.files.get`, returns the `httpx.Response`, which the caller reads or
43
+ closes.
44
+
45
+ ## Credentials
46
+
47
+ Give one credential. A credential in the options replaces every credential in the environment.
48
+
49
+ | Option | Variable | Use |
50
+ | ------------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
51
+ | `private_key` | `PIERRE_PRIVATE_KEY`, or the file at `PIERRE_PRIVATE_KEY_FILE` | The SDK signs a 5-minute token for each request, with only the scopes of the operation. |
52
+ | `token` | `PIERRE_TOKEN` | A fixed token. The server checks its scopes. |
53
+ | `get_token` | none | A function that returns a token for each request, for a client with no private key. |
54
+
55
+ With no credential in the options, the SDK uses the first variable that is set: `PIERRE_TOKEN`, then
56
+ `PIERRE_PRIVATE_KEY`, then `PIERRE_PRIVATE_KEY_FILE`.
57
+
58
+ `org` (`PIERRE_ORG`) names the organization. With `token`, the SDK reads it from the `iss` claim.
59
+ `base_url` (`PIERRE_API_BASE_URL`) and `git_host` (`PIERRE_GIT_HOST`) replace the default hosts,
60
+ `https://api.{org}.code.storage` and `{org}.code.storage`. The base URL ends before `/api`, because
61
+ each operation path starts with `/api`: for example `https://api.acme.code.storage`, not
62
+ `https://api.acme.code.storage/api/v1`. A path in front of `/api`, such as the prefix of a proxy,
63
+ stays in the base URL. The Git host is a host name with an optional port and no scheme, for example
64
+ `acme.code.storage`.
65
+
66
+ ## Options
67
+
68
+ The client options are `org`, `private_key`, `token`, `get_token`, `base_url`, `git_host`, `timeout`
69
+ (seconds, default 60), `max_retries` (default 2), `default_headers`, `http_client`, and
70
+ `ref_policies`. `pierre.options` holds the settings with no credential, and `pierre.with_options()`
71
+ returns a copy with changed options.
72
+
73
+ A client keeps one httpx client. `with Pierre() as pierre:` and
74
+ `async with AsyncPierre() as pierre:` close the httpx client that the SDK made at the end of the
75
+ block. An `http_client` that you give stays open.
76
+
77
+ Each method also takes the request options `extra_headers`, `timeout`, `max_retries`,
78
+ `idempotency_key`, and `ref_policies` for one call.
79
+
80
+ `idempotency_key` applies only to an operation that accepts an `Idempotency-Key`. On any other
81
+ operation, the call raises `PierreError` and sends no request.
82
+
83
+ An optional argument has the default `NOT_GIVEN`, which the SDK does not send. `None` sends `null`.
84
+
85
+ ## Responses, pages, and errors
86
+
87
+ - `pierre.with_raw_response` has the namespaces of the client. Each method returns a `RawResponse`
88
+ with `data`, `response` (the `httpx.Response`), `headers` (the declared response headers), and
89
+ `request_id`.
90
+ - A list method returns a `Page` in `Pierre`. In `AsyncPierre`, it returns an `AsyncPaginator`:
91
+ `await` gives the first `AsyncPage`, and `async for` gives every item. A page has `data`,
92
+ `has_more`, `next_cursor`, `body`, `response`, `has_next_page()`, `get_next_page()`, and
93
+ `iter_pages()`. To serialize a page, serialize `page.body`, the response that the API sent.
94
+ - Every error extends `PierreError`. An HTTP error is an `APIError` with `status`, `code`, `title`,
95
+ `detail`, `request_id`, `headers`, `body`, and `doc_url`, with a subclass for each status family,
96
+ and `MergeConflictError` and `RefUpdateError` for codes. `RefUpdateError.result` is a
97
+ `RefUpdateResult`, or a `NotesWriteResult` for a notes write, so `error.result["status"]` gives
98
+ the reason with no cast, for example `conflict`. A failed ref guard, with the code
99
+ `ref_guard_failed`, raises `RefGuardError`, a `ConflictError` with `guard` and `current_sha`: send
100
+ `current_sha` as the guard of the next attempt.
101
+
102
+ ## Local utilities
103
+
104
+ Import the modules of the local utilities before you name a client `pierre`, because the client name
105
+ hides the package:
106
+
107
+ ```python
108
+ from pierre import Pierre, auth, git, webhooks
109
+
110
+ pierre = Pierre()
111
+ token = auth.create_token(pierre, scopes=["git:read"], repo="acme/web")
112
+ url = git.remote_url(pierre, repo_name="acme/web")
113
+ ```
114
+
115
+ - `auth.create_token(client, scopes=[...])` signs a token with no HTTP call. `auth.SCOPES` lists the
116
+ scopes of the API, and `auth.Scope` is their type.
117
+ - `git.remote_url(client, repo_name=...)` builds a Git remote URL with a 15-minute token. With
118
+ `AsyncPierre`, await the result.
119
+ - `webhooks.verify_webhook(payload=..., headers=..., secret=...)` checks a webhook delivery and
120
+ returns the typed event.
121
+
122
+ ## Differences from the TypeScript SDK
123
+
124
+ - A timeout is in seconds, as in `httpx`. It covers each attempt: the token, the upload, the
125
+ response headers, and a JSON body. `Pierre` cannot stop a blocking `get_token`, so the attempt
126
+ fails when the token arrives after the deadline.
127
+ - There is no `signal`. To stop an `AsyncPierre` call, cancel its task.
128
+ - An async method starts its request when the caller awaits it, as a coroutine does.
129
+ - `pierre.with_raw_response` replaces `withResponse()`. The SDK reads the body of a JSON response,
130
+ so there is no `asResponse()`. A byte response stays a stream.
@@ -0,0 +1,92 @@
1
+ [project]
2
+ name = "pierre-sdk"
3
+ version = "0.1.0"
4
+ description = "The Pierre SDK for Python"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.10"
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Intended Audience :: Developers",
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3.10",
14
+ "Programming Language :: Python :: 3.11",
15
+ "Programming Language :: Python :: 3.12",
16
+ "Programming Language :: Python :: 3.13",
17
+ "Typing :: Typed",
18
+ ]
19
+ dependencies = [
20
+ "cryptography>=41.0.0",
21
+ "httpx>=0.27.0,<1",
22
+ "typing-extensions>=4.5.0; python_version < '3.11'",
23
+ ]
24
+
25
+ [[project.authors]]
26
+ name = "Pierre"
27
+ email = "support@pierre.co"
28
+
29
+ [project.urls]
30
+ Homepage = "https://pierre.computer"
31
+
32
+ [dependency-groups]
33
+ dev = [
34
+ "mypy>=1.5.0",
35
+ "pytest>=7.4.0",
36
+ "pytest-asyncio>=0.21.0",
37
+ "pytest-cov>=4.1.0",
38
+ "ruff>=0.1.0",
39
+ ]
40
+
41
+ [build-system]
42
+ requires = ["uv_build>=0.12.0,<0.13"]
43
+ build-backend = "uv_build"
44
+
45
+ [tool.uv]
46
+ python-preference = "only-system"
47
+ python-downloads = "never"
48
+
49
+ [tool.uv.build-backend]
50
+ module-name = "pierre"
51
+
52
+ [tool.pytest.ini_options]
53
+ testpaths = ["tests"]
54
+ asyncio_mode = "auto"
55
+ asyncio_default_fixture_loop_scope = "function"
56
+
57
+ [tool.mypy]
58
+ python_version = "3.10"
59
+ strict = true
60
+ files = [
61
+ "src",
62
+ "tests",
63
+ "scripts",
64
+ ]
65
+
66
+ [tool.ruff]
67
+ line-length = 100
68
+ target-version = "py310"
69
+
70
+ [tool.ruff.lint]
71
+ select = [
72
+ "E",
73
+ "F",
74
+ "I",
75
+ "N",
76
+ "W",
77
+ "B",
78
+ "C4",
79
+ "SIM",
80
+ ]
81
+ ignore = ["E501"]
82
+
83
+ [tool.ruff.lint.per-file-ignores]
84
+ "src/pierre/_generated/**" = [
85
+ "N803",
86
+ "N815",
87
+ ]
88
+ "tests/**" = [
89
+ "N802",
90
+ "N803",
91
+ "N815",
92
+ ]
@@ -0,0 +1,92 @@
1
+ [project]
2
+ name = "pierre-sdk"
3
+ version = "0.1.0"
4
+ description = "The Pierre SDK for Python"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.10"
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Intended Audience :: Developers",
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3.10",
14
+ "Programming Language :: Python :: 3.11",
15
+ "Programming Language :: Python :: 3.12",
16
+ "Programming Language :: Python :: 3.13",
17
+ "Typing :: Typed",
18
+ ]
19
+ dependencies = [
20
+ "cryptography>=41.0.0",
21
+ "httpx>=0.27.0,<1",
22
+ "typing-extensions>=4.5.0; python_version < '3.11'",
23
+ ]
24
+
25
+ [[project.authors]]
26
+ name = "Pierre"
27
+ email = "support@pierre.co"
28
+
29
+ [project.urls]
30
+ Homepage = "https://pierre.computer"
31
+
32
+ [dependency-groups]
33
+ dev = [
34
+ "mypy>=1.5.0",
35
+ "pytest>=7.4.0",
36
+ "pytest-asyncio>=0.21.0",
37
+ "pytest-cov>=4.1.0",
38
+ "ruff>=0.1.0",
39
+ ]
40
+
41
+ [build-system]
42
+ requires = ["uv_build>=0.12.0,<0.13"]
43
+ build-backend = "uv_build"
44
+
45
+ [tool.uv]
46
+ python-preference = "only-system"
47
+ python-downloads = "never"
48
+
49
+ [tool.uv.build-backend]
50
+ module-name = "pierre"
51
+
52
+ [tool.pytest.ini_options]
53
+ testpaths = ["tests"]
54
+ asyncio_mode = "auto"
55
+ asyncio_default_fixture_loop_scope = "function"
56
+
57
+ [tool.mypy]
58
+ python_version = "3.10"
59
+ strict = true
60
+ files = [
61
+ "src",
62
+ "tests",
63
+ "scripts",
64
+ ]
65
+
66
+ [tool.ruff]
67
+ line-length = 100
68
+ target-version = "py310"
69
+
70
+ [tool.ruff.lint]
71
+ select = [
72
+ "E",
73
+ "F",
74
+ "I",
75
+ "N",
76
+ "W",
77
+ "B",
78
+ "C4",
79
+ "SIM",
80
+ ]
81
+ ignore = ["E501"]
82
+
83
+ [tool.ruff.lint.per-file-ignores]
84
+ "src/pierre/_generated/**" = [
85
+ "N803",
86
+ "N815",
87
+ ]
88
+ "tests/**" = [
89
+ "N802",
90
+ "N803",
91
+ "N815",
92
+ ]