You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+173-9Lines changed: 173 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,7 @@ More information about the API can be found at https://clerk.com/docs
34
34
*[Retries](#retries)
35
35
*[Error Handling](#error-handling)
36
36
*[Server Selection](#server-selection)
37
+
*[Custom HTTP Client](#custom-http-client)
37
38
*[Debugging](#debugging)
38
39
*[Development](#development)
39
40
*[Contributions](#contributions)
@@ -51,15 +52,15 @@ The samples below show how a published SDK artifact is used:
51
52
52
53
Gradle:
53
54
```groovy
54
-
implementation 'com.clerk:backend-api:3.2.0'
55
+
implementation 'com.clerk:backend-api:3.3.0'
55
56
```
56
57
57
58
Maven:
58
59
```xml
59
60
<dependency>
60
61
<groupId>com.clerk</groupId>
61
62
<artifactId>backend-api</artifactId>
62
-
<version>3.2.0</version>
63
+
<version>3.3.0</version>
63
64
</dependency>
64
65
```
65
66
@@ -226,7 +227,6 @@ public class MachineAuthentication {
226
227
* [create](docs/sdks/blocklistidentifiers/README.md#create) -Add identifier to the block-list
227
228
* [delete](docs/sdks/blocklistidentifiers/README.md#delete) -Delete identifier from block-list
228
229
229
-
230
230
### [clients()](docs/sdks/clients/README.md)
231
231
232
232
* [~~list~~](docs/sdks/clients/README.md#list) -List all clients :warning:**Deprecated**
@@ -238,6 +238,7 @@ public class MachineAuthentication {
238
238
* [listPlans](docs/sdks/commerce/README.md#listplans) -List all commerce plans
239
239
* [listSubscriptionItems](docs/sdks/commerce/README.md#listsubscriptionitems) -List all subscription items
240
240
* [cancelSubscriptionItem](docs/sdks/commerce/README.md#cancelsubscriptionitem) -Cancel a subscription item
241
+
* [extendSubscriptionItemFreeTrial](docs/sdks/commerce/README.md#extendsubscriptionitemfreetrial) -Extend free trial for a subscription item
241
242
242
243
### [domains()](docs/sdks/domains/README.md)
243
244
@@ -311,6 +312,7 @@ public class MachineAuthentication {
311
312
* [update](docs/sdks/machines/README.md#update) -Update a machine
312
313
* [delete](docs/sdks/machines/README.md#delete) -Delete a machine
313
314
* [getSecretKey](docs/sdks/machines/README.md#getsecretkey) -Retrieve a machine secret key
315
+
* [rotateSecretKey](docs/sdks/machines/README.md#rotatesecretkey) -Rotate a machine's secret key
314
316
* [createScope](docs/sdks/machines/README.md#createscope) - Create a machine scope
315
317
* [deleteScope](docs/sdks/machines/README.md#deletescope) - Delete a machine scope
316
318
@@ -458,6 +460,7 @@ public class MachineAuthentication {
458
460
459
461
* [list](docs/sdks/waitlistentries/README.md#list) -List all waitlist entries
460
462
* [create](docs/sdks/waitlistentries/README.md#create) -Create a waitlist entry
463
+
* [delete](docs/sdks/waitlistentries/README.md#delete) -Delete a pending waitlist entry
461
464
* [invite](docs/sdks/waitlistentries/README.md#invite) -Invite a waitlist entry
462
465
* [reject](docs/sdks/waitlistentries/README.md#reject) -Reject a waitlist entry
463
466
@@ -553,15 +556,19 @@ public class Application {
553
556
554
557
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.
555
558
556
-
Bydefault, an API error will throw a `models/errors/SDKError` exception. When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `delete` method throws the following exceptions:
| `body()` | `byte[]` | HTTP body as a byte array. Can be empty array if no body is returned. |
568
+
| `bodyAsString()` | `String` | HTTP body as a UTF-8 string. Can be empty string if no body is returned. |
569
+
| `rawResponse()` | `HttpResponse<?>` | Raw HTTP response (body already read and not available for re-read) |
564
570
571
+
### Example
565
572
```java
566
573
package hello.world;
567
574
@@ -588,6 +595,38 @@ public class Application {
588
595
}
589
596
}
590
597
```
598
+
599
+
### Error Classes
600
+
**Primary errors:**
601
+
* [`ClerkError`](./src/main/java/models/errors/ClerkError.java): The base class for HTTP error responses.
602
+
* [`com.clerk.backend_api.models.errors.ClerkErrors`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.ClerkErrors.java): Request was not successful. *
603
+
604
+
<details><summary>Less common errors (17)</summary>
605
+
606
+
<br />
607
+
608
+
**Network errors:**
609
+
* `java.io.IOException` (always wrapped by `java.io.UncheckedIOException`). Commonly encountered subclasses of
610
+
`IOException` include `java.net.ConnectException`, `java.net.SocketTimeoutException`, `EOFException` (there are
611
+
many more subclasses in the JDK platform).
612
+
613
+
**Inherit from [`ClerkError`](./src/main/java/models/errors/ClerkError.java)**:
614
+
* [`com.clerk.backend_api.models.errors.CreateM2MTokenResponseBody`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.CreateM2MTokenResponseBody.java): 400 Bad Request. Status code `400`. Applicable to 1 of 159 methods.*
615
+
* [`com.clerk.backend_api.models.errors.GetM2MTokensResponseBody`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.GetM2MTokensResponseBody.java): 400 Bad Request. Status code `400`. Applicable to 1 of 159 methods.*
616
+
* [`com.clerk.backend_api.models.errors.RevokeM2MTokenResponseBody`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.RevokeM2MTokenResponseBody.java): 400 Bad Request. Status code `400`. Applicable to 1 of 159 methods.*
617
+
* [`com.clerk.backend_api.models.errors.VerifyM2MTokenResponseBody`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.VerifyM2MTokenResponseBody.java): 400 Bad Request. Status code `400`. Applicable to 1 of 159 methods.*
618
+
* [`com.clerk.backend_api.models.errors.VerifyOAuthAccessTokenResponseBody`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.VerifyOAuthAccessTokenResponseBody.java): 400 Bad Request. Status code `400`. Applicable to 1 of 159 methods.*
619
+
* [`com.clerk.backend_api.models.errors.GetM2MTokensM2mResponseBody`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.GetM2MTokensM2mResponseBody.java): 403 Forbidden. Status code `403`. Applicable to 1 of 159 methods.*
620
+
* [`com.clerk.backend_api.models.errors.GetM2MTokensM2mResponseResponseBody`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.GetM2MTokensM2mResponseResponseBody.java): 404 Not Found. Status code `404`. Applicable to 1 of 159 methods.*
621
+
* [`com.clerk.backend_api.models.errors.RevokeM2MTokenM2mResponseBody`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.RevokeM2MTokenM2mResponseBody.java): 404 Not Found. Status code `404`. Applicable to 1 of 159 methods.*
622
+
* [`com.clerk.backend_api.models.errors.VerifyM2MTokenM2mResponseBody`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.VerifyM2MTokenM2mResponseBody.java): 404 Not Found. Status code `404`. Applicable to 1 of 159 methods.*
623
+
* [`com.clerk.backend_api.models.errors.VerifyOAuthAccessTokenOauthAccessTokensResponseBody`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.VerifyOAuthAccessTokenOauthAccessTokensResponseBody.java): 404 Not Found. Status code `404`. Applicable to 1 of 159 methods.*
624
+
* [`com.clerk.backend_api.models.errors.CreateM2MTokenM2mResponseBody`](./src/main/java/models/errors/com.clerk.backend_api.models.errors.CreateM2MTokenM2mResponseBody.java): 409 Conflict. Status code `409`. Applicable to 1 of 159 methods.*
625
+
626
+
627
+
</details>
628
+
629
+
\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
591
630
<!-- End Error Handling [errors] -->
592
631
593
632
<!-- Start Server Selection [server] -->
@@ -621,6 +660,131 @@ public class Application {
621
660
<!-- End Server Selection [server] -->
622
661
623
662
663
+
<!-- Start Custom HTTP Client [http-client] -->
664
+
## Custom HTTP Client
665
+
666
+
The Java SDK makes API calls using an `HTTPClient` that wraps the native
667
+
[HttpClient](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html). This
668
+
client provides the ability to attach hooks around the request lifecycle that can be used to modify the request or handle
669
+
errors and response.
670
+
671
+
The `HTTPClient` interface allows you to either use the default `SpeakeasyHTTPClient` that comes with the SDK,
672
+
or provide your own custom implementation with customized configuration such as custom executors, SSL context,
673
+
connection pools, and other HTTP client settings.
674
+
675
+
The interface provides synchronous (`send`) methods.
676
+
677
+
The following example shows how to add a custom header and handle errors:
0 commit comments