Developer-friendly & type-safe Java SDK specifically catered to leverage openapi API.
Important
This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.
Twilio - Voice: This is the public Twilio REST API.
JDK 11 or later is required.
The samples below show how a published SDK artifact is used:
Gradle:
implementation 'org.openapis:openapi:0.1.0'Maven:
<dependency>
<groupId>org.openapis</groupId>
<artifactId>openapi</artifactId>
<version>0.1.0</version>
</dependency>After cloning the git repository to your file system you can build the SDK artifact from source to the build directory by running ./gradlew build on *nix systems or gradlew.bat on Windows systems.
If you wish to build from source and publish the SDK artifact to your local Maven repository (on your filesystem) then use the following command (after cloning the git repo locally):
On *nix:
./gradlew publishToMavenLocal -Pskip.signingOn Windows:
gradlew.bat publishToMavenLocal -Pskip.signingpackage hello.world;
import java.lang.Exception;
import java.time.LocalDate;
import org.openapis.openapi.SDK;
import org.openapis.openapi.models.components.Security;
import org.openapis.openapi.models.operations.DeleteArchivedCallResponse;
public class Application {
public static void main(String[] args) throws Exception {
SDK sdk = SDK.builder()
.security(Security.builder()
.username("")
.password("")
.build())
.build();
DeleteArchivedCallResponse res = sdk.voiceV1ArchivedCall().deleteArchivedCall()
.date(LocalDate.parse("2024-07-27"))
.sid("<id>")
.call();
// handle response
}
}This SDK supports the following security scheme globally:
| Name | Type | Scheme |
|---|---|---|
usernamepassword |
http | HTTP Basic |
You can set the security parameters through the security builder method when initializing the SDK client instance. For example:
package hello.world;
import java.lang.Exception;
import java.time.LocalDate;
import org.openapis.openapi.SDK;
import org.openapis.openapi.models.components.Security;
import org.openapis.openapi.models.operations.DeleteArchivedCallResponse;
public class Application {
public static void main(String[] args) throws Exception {
SDK sdk = SDK.builder()
.security(Security.builder()
.username("")
.password("")
.build())
.build();
DeleteArchivedCallResponse res = sdk.voiceV1ArchivedCall().deleteArchivedCall()
.date(LocalDate.parse("2024-07-27"))
.sid("<id>")
.call();
// handle response
}
}Available methods
- deleteArchivedCall - Delete an archived call record from Bulk Export. Note: this does not also delete the record from the Voice API.
- createDialingPermissionsCountryBulkUpdate - Create a bulk update request to change voice dialing country permissions of one or more countries identified by the corresponding ISO country code
- createConnectionPolicy
- listConnectionPolicy
- fetchConnectionPolicy
- updateConnectionPolicy
- deleteConnectionPolicy
- createConnectionPolicyTarget
- listConnectionPolicyTarget
- fetchConnectionPolicyTarget
- updateConnectionPolicyTarget
- deleteConnectionPolicyTarget
- fetchDialingPermissionsCountry - Retrieve voice dialing country permissions identified by the given ISO country code
- listDialingPermissionsCountry - Retrieve all voice dialing country permissions for this account
- listDialingPermissionsHrsPrefixes - Fetch the high-risk special services prefixes from the country resource corresponding to the ISO country code
- fetchDialingPermissionsSettings - Retrieve voice dialing permissions inheritance for the sub-account
- updateDialingPermissionsSettings - Update voice dialing permissions inheritance for the sub-account
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.
By default, an API error will throw a models/errors/APIException 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 deleteArchivedCall method throws the following exceptions:
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/APIException | 4XX, 5XX | */* |
package hello.world;
import java.lang.Exception;
import java.time.LocalDate;
import org.openapis.openapi.SDK;
import org.openapis.openapi.models.components.Security;
import org.openapis.openapi.models.operations.DeleteArchivedCallResponse;
public class Application {
public static void main(String[] args) throws Exception {
SDK sdk = SDK.builder()
.security(Security.builder()
.username("")
.password("")
.build())
.build();
DeleteArchivedCallResponse res = sdk.voiceV1ArchivedCall().deleteArchivedCall()
.date(LocalDate.parse("2024-07-27"))
.sid("<id>")
.call();
// handle response
}
}The default server can be overridden globally using the .serverURL(String serverUrl) builder method when initializing the SDK client instance. For example:
package hello.world;
import java.lang.Exception;
import java.time.LocalDate;
import org.openapis.openapi.SDK;
import org.openapis.openapi.models.components.Security;
import org.openapis.openapi.models.operations.DeleteArchivedCallResponse;
public class Application {
public static void main(String[] args) throws Exception {
SDK sdk = SDK.builder()
.serverURL("https://voice.twilio.com")
.security(Security.builder()
.username("")
.password("")
.build())
.build();
DeleteArchivedCallResponse res = sdk.voiceV1ArchivedCall().deleteArchivedCall()
.date(LocalDate.parse("2024-07-27"))
.sid("<id>")
.call();
// handle response
}
}The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:
package hello.world;
import java.lang.Exception;
import java.time.LocalDate;
import org.openapis.openapi.SDK;
import org.openapis.openapi.models.components.Security;
import org.openapis.openapi.models.operations.DeleteArchivedCallResponse;
public class Application {
public static void main(String[] args) throws Exception {
SDK sdk = SDK.builder()
.security(Security.builder()
.username("")
.password("")
.build())
.build();
DeleteArchivedCallResponse res = sdk.voiceV1ArchivedCall().deleteArchivedCall()
.serverURL("https://voice.twilio.com")
.date(LocalDate.parse("2024-07-27"))
.sid("<id>")
.call();
// handle response
}
}This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.