diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 3bea478..b193d1b 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -3,17 +3,17 @@ id: f42d74f5-5725-46fa-b13c-649b7ef895c3 management: docChecksum: 32687d9ba29da014326cc097fdfff59d docVersion: 1.0.0 - speakeasyVersion: 1.583.0 - generationVersion: 2.658.3 - releaseVersion: 0.3.0 - configChecksum: 04772eab57280291f66f591afacc7c70 + speakeasyVersion: 1.605.0 + generationVersion: 2.684.0 + releaseVersion: 0.4.0 + configChecksum: 64280e9b75ae7cae2bf294597c2b036a repoURL: https://github.com/VantaInc/vanta-auditor-api-sdk-java.git published: true features: java: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.1 - core: 3.44.0 + core: 3.45.3 flattening: 2.81.1 globalSecurity: 2.83.0 globalSecurityCallbacks: 0.1.0 @@ -177,17 +177,17 @@ generatedFiles: - src/main/java/com/vanta/vanta_auditor_api/models/operations/UpdateAuditEvidenceRequest.java - src/main/java/com/vanta/vanta_auditor_api/models/operations/UpdateAuditEvidenceRequestBuilder.java - src/main/java/com/vanta/vanta_auditor_api/models/operations/UpdateAuditEvidenceResponse.java - - src/main/java/com/vanta/vanta_auditor_api/operations/CreateAuditorOperation.java - - src/main/java/com/vanta/vanta_auditor_api/operations/CreateCommentForAuditEvidenceOperation.java - - src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomControlOperation.java - - src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomEvidenceRequestOperation.java - - src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditCommentsOperation.java - - src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditControlsOperation.java - - src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceOperation.java - - src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceUrlsOperation.java - - src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditsOperation.java + - src/main/java/com/vanta/vanta_auditor_api/operations/CreateAuditor.java + - src/main/java/com/vanta/vanta_auditor_api/operations/CreateCommentForAuditEvidence.java + - src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomControl.java + - src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomEvidenceRequest.java + - src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditComments.java + - src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditControls.java + - src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidence.java + - src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceUrls.java + - src/main/java/com/vanta/vanta_auditor_api/operations/ListAudits.java - src/main/java/com/vanta/vanta_auditor_api/operations/Operations.java - - src/main/java/com/vanta/vanta_auditor_api/operations/UpdateAuditEvidenceOperation.java + - src/main/java/com/vanta/vanta_auditor_api/operations/UpdateAuditEvidence.java - src/main/java/com/vanta/vanta_auditor_api/utils/BackoffStrategy.java - src/main/java/com/vanta/vanta_auditor_api/utils/BigDecimalString.java - src/main/java/com/vanta/vanta_auditor_api/utils/BigIntegerString.java @@ -225,6 +225,7 @@ generatedFiles: - src/main/java/com/vanta/vanta_auditor_api/utils/RequestBody.java - src/main/java/com/vanta/vanta_auditor_api/utils/RequestMetadata.java - src/main/java/com/vanta/vanta_auditor_api/utils/Response.java + - src/main/java/com/vanta/vanta_auditor_api/utils/ResponseWithBody.java - src/main/java/com/vanta/vanta_auditor_api/utils/Retries.java - src/main/java/com/vanta/vanta_auditor_api/utils/RetryConfig.java - src/main/java/com/vanta/vanta_auditor_api/utils/Security.java diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index fc8f38b..3e1ea7a 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -21,7 +21,7 @@ generation: generateNewTests: false skipResponseBodyAssertions: false java: - version: 0.3.0 + version: 0.4.0 additionalDependencies: [] additionalPlugins: [] artifactID: vanta-auditor-api diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 3eb1b7e..882fef1 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,4 +1,4 @@ -speakeasyVersion: 1.583.0 +speakeasyVersion: 1.605.0 sources: Conduct an audit: sourceNamespace: conduct-an-audit @@ -6,7 +6,7 @@ sources: sourceBlobDigest: sha256:8fefc2fa168b537a6f137983f6366a1d8abe9ea0a01bc6d108c601431b922a5b tags: - latest - - speakeasy-sdk-regen-1752711959 + - speakeasy-sdk-regen-1754439995 - 1.0.0 targets: vanta: @@ -15,7 +15,7 @@ targets: sourceRevisionDigest: sha256:234b914b23cf5d74d33cd7077560a45c8cba13a211f3bd8344041648d8733c2d sourceBlobDigest: sha256:8fefc2fa168b537a6f137983f6366a1d8abe9ea0a01bc6d108c601431b922a5b codeSamplesNamespace: conduct-an-audit-java-code-samples - codeSamplesRevisionDigest: sha256:c37b408b3f4e67573812e3180585ed44685609283ecc89a119faafece26cadcc + codeSamplesRevisionDigest: sha256:8978f388ac1114cfcdd1b15a7fbf455f865fae74b8d45d74f145f7e4a350450b workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index 831be0c..f45baa1 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ The samples below show how a published SDK artifact is used: Gradle: ```groovy -implementation 'com.vanta:vanta-auditor-api:0.3.0' +implementation 'com.vanta:vanta-auditor-api:0.4.0' ``` Maven: @@ -52,7 +52,7 @@ Maven: com.vanta vanta-auditor-api - 0.3.0 + 0.4.0 ``` diff --git a/RELEASES.md b/RELEASES.md index 0cad73c..0671f40 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -18,4 +18,14 @@ Based on: ### Generated - [java v0.3.0] . ### Releases -- [Maven Central v0.3.0] https://central.sonatype.com/artifact/com.vanta/vanta-auditor-api/0.3.0 - . \ No newline at end of file +- [Maven Central v0.3.0] https://central.sonatype.com/artifact/com.vanta/vanta-auditor-api/0.3.0 - . + +## 2025-08-16 00:23:17 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.605.0 (2.684.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [java v0.4.0] . +### Releases +- [Maven Central v0.4.0] https://central.sonatype.com/artifact/com.vanta/vanta-auditor-api/0.4.0 - . \ No newline at end of file diff --git a/build.gradle b/build.gradle index f148620..9d5e850 100644 --- a/build.gradle +++ b/build.gradle @@ -59,7 +59,7 @@ javadoc { } tasks.withType(Javadoc) { - failOnError false + failOnError = false options.addStringOption('Xdoclint:none', '-quiet') } @@ -105,7 +105,7 @@ publishing { // https://github.com/gradle/gradle/issues/18619 groupId = "com.vanta" artifactId = "vanta-auditor-api" - version = "0.3.0" + version = "0.4.0" from components.java diff --git a/docs/sdks/auditors/README.md b/docs/sdks/auditors/README.md index b2ecfda..be0a37e 100644 --- a/docs/sdks/auditors/README.md +++ b/docs/sdks/auditors/README.md @@ -13,6 +13,7 @@ Create an auditor in Vanta. ### Example Usage + ```java package hello.world; diff --git a/docs/sdks/audits/README.md b/docs/sdks/audits/README.md index 85ef1a0..f1e4a07 100644 --- a/docs/sdks/audits/README.md +++ b/docs/sdks/audits/README.md @@ -21,6 +21,7 @@ Returns a paginated list of audits scoped to the audit firm. ### Example Usage + ```java package hello.world; @@ -73,6 +74,7 @@ evidence is created or has a statusUpdatedAt field that is more recent than the ### Example Usage + ```java package hello.world; @@ -126,6 +128,7 @@ Returns a paginated list of evidence for an audit. ### Example Usage + ```java package hello.world; @@ -178,6 +181,7 @@ Returns a paginated list of comments for an audit. ### Example Usage + ```java package hello.world; @@ -230,6 +234,7 @@ Returns a paginated list of controls for an audit. ### Example Usage + ```java package hello.world; @@ -281,6 +286,7 @@ Create a comment in Vanta for a piece of evidence. ### Example Usage + ```java package hello.world; @@ -339,6 +345,7 @@ Update audit evidence. ### Example Usage + ```java package hello.world; @@ -393,6 +400,7 @@ Create a custom evidence request for an audit. ### Example Usage + ```java package hello.world; @@ -456,6 +464,7 @@ Create a custom control for an audit. ### Example Usage + ```java package hello.world; diff --git a/gradle.properties b/gradle.properties index cc9349c..62c0a5b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ groupId=com.vanta artifactId=vanta-auditor-api -version=0.3.0 \ No newline at end of file +version=0.4.0 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd49..1b33c55 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e09..ff23a68 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4..23d15a9 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -203,7 +205,7 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. @@ -211,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 6689b85..5eed7ee 100755 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,22 +59,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/src/main/java/com/vanta/vanta_auditor_api/Auditors.java b/src/main/java/com/vanta/vanta_auditor_api/Auditors.java index b047cc8..d594d10 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/Auditors.java +++ b/src/main/java/com/vanta/vanta_auditor_api/Auditors.java @@ -8,7 +8,7 @@ import com.vanta.vanta_auditor_api.models.components.AddAuditorInput; import com.vanta.vanta_auditor_api.models.operations.CreateAuditorRequestBuilder; import com.vanta.vanta_auditor_api.models.operations.CreateAuditorResponse; -import com.vanta.vanta_auditor_api.operations.CreateAuditorOperation; +import com.vanta.vanta_auditor_api.operations.CreateAuditor; import java.lang.Exception; @@ -41,7 +41,7 @@ public CreateAuditorRequestBuilder create() { */ public CreateAuditorResponse create(AddAuditorInput request) throws Exception { RequestOperation operation - = new CreateAuditorOperation(sdkConfiguration); + = new CreateAuditor.Sync(sdkConfiguration); return operation.handleResponse(operation.doRequest(request)); } diff --git a/src/main/java/com/vanta/vanta_auditor_api/Audits.java b/src/main/java/com/vanta/vanta_auditor_api/Audits.java index da12d16..271be94 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/Audits.java +++ b/src/main/java/com/vanta/vanta_auditor_api/Audits.java @@ -36,15 +36,15 @@ import com.vanta.vanta_auditor_api.models.operations.UpdateAuditEvidenceRequest; import com.vanta.vanta_auditor_api.models.operations.UpdateAuditEvidenceRequestBuilder; import com.vanta.vanta_auditor_api.models.operations.UpdateAuditEvidenceResponse; -import com.vanta.vanta_auditor_api.operations.CreateCommentForAuditEvidenceOperation; -import com.vanta.vanta_auditor_api.operations.CreateCustomControlOperation; -import com.vanta.vanta_auditor_api.operations.CreateCustomEvidenceRequestOperation; -import com.vanta.vanta_auditor_api.operations.ListAuditCommentsOperation; -import com.vanta.vanta_auditor_api.operations.ListAuditControlsOperation; -import com.vanta.vanta_auditor_api.operations.ListAuditEvidenceOperation; -import com.vanta.vanta_auditor_api.operations.ListAuditEvidenceUrlsOperation; -import com.vanta.vanta_auditor_api.operations.ListAuditsOperation; -import com.vanta.vanta_auditor_api.operations.UpdateAuditEvidenceOperation; +import com.vanta.vanta_auditor_api.operations.CreateCommentForAuditEvidence; +import com.vanta.vanta_auditor_api.operations.CreateCustomControl; +import com.vanta.vanta_auditor_api.operations.CreateCustomEvidenceRequest; +import com.vanta.vanta_auditor_api.operations.ListAuditComments; +import com.vanta.vanta_auditor_api.operations.ListAuditControls; +import com.vanta.vanta_auditor_api.operations.ListAuditEvidence; +import com.vanta.vanta_auditor_api.operations.ListAuditEvidenceUrls; +import com.vanta.vanta_auditor_api.operations.ListAudits; +import com.vanta.vanta_auditor_api.operations.UpdateAuditEvidence; import java.lang.Boolean; import java.lang.Exception; import java.lang.Integer; @@ -108,7 +108,7 @@ public ListAuditsResponse list( .isActiveAudit(isActiveAudit) .build(); RequestOperation operation - = new ListAuditsOperation(sdkConfiguration); + = new ListAudits.Sync(sdkConfiguration); return operation.handleResponse(operation.doRequest(request)); } @@ -165,7 +165,7 @@ public ListAuditEvidenceUrlsResponse getEvidenceUrls( .pageCursor(pageCursor) .build(); RequestOperation operation - = new ListAuditEvidenceUrlsOperation(sdkConfiguration); + = new ListAuditEvidenceUrls.Sync(sdkConfiguration); return operation.handleResponse(operation.doRequest(request)); } @@ -218,7 +218,7 @@ public ListAuditEvidenceResponse listEvidence( .changedSinceDate(changedSinceDate) .build(); RequestOperation operation - = new ListAuditEvidenceOperation(sdkConfiguration); + = new ListAuditEvidence.Sync(sdkConfiguration); return operation.handleResponse(operation.doRequest(request)); } @@ -271,7 +271,7 @@ public ListAuditCommentsResponse listComments( .changedSinceDate(changedSinceDate) .build(); RequestOperation operation - = new ListAuditCommentsOperation(sdkConfiguration); + = new ListAuditComments.Sync(sdkConfiguration); return operation.handleResponse(operation.doRequest(request)); } @@ -321,7 +321,7 @@ public ListAuditControlsResponse listControls( .pageCursor(pageCursor) .build(); RequestOperation operation - = new ListAuditControlsOperation(sdkConfiguration); + = new ListAuditControls.Sync(sdkConfiguration); return operation.handleResponse(operation.doRequest(request)); } @@ -358,7 +358,7 @@ public CreateCommentForAuditEvidenceResponse createCommentForEvidence( .addCommentInput(addCommentInput) .build(); RequestOperation operation - = new CreateCommentForAuditEvidenceOperation(sdkConfiguration); + = new CreateCommentForAuditEvidence.Sync(sdkConfiguration); return operation.handleResponse(operation.doRequest(request)); } @@ -395,7 +395,7 @@ public UpdateAuditEvidenceResponse updateEvidence( .auditEvidenceUpdateInput(auditEvidenceUpdateInput) .build(); RequestOperation operation - = new UpdateAuditEvidenceOperation(sdkConfiguration); + = new UpdateAuditEvidence.Sync(sdkConfiguration); return operation.handleResponse(operation.doRequest(request)); } @@ -428,7 +428,7 @@ public CreateCustomEvidenceRequestResponse createCustomEvidenceRequest(String au .createCustomEvidenceRequestInput(createCustomEvidenceRequestInput) .build(); RequestOperation operation - = new CreateCustomEvidenceRequestOperation(sdkConfiguration); + = new CreateCustomEvidenceRequest.Sync(sdkConfiguration); return operation.handleResponse(operation.doRequest(request)); } @@ -461,7 +461,7 @@ public CreateCustomControlResponse createCustomControl(String auditId, CreateCus .createCustomControlInput(createCustomControlInput) .build(); RequestOperation operation - = new CreateCustomControlOperation(sdkConfiguration); + = new CreateCustomControl.Sync(sdkConfiguration); return operation.handleResponse(operation.doRequest(request)); } diff --git a/src/main/java/com/vanta/vanta_auditor_api/SDKConfiguration.java b/src/main/java/com/vanta/vanta_auditor_api/SDKConfiguration.java index 6ad8520..bfe4c4d 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/SDKConfiguration.java +++ b/src/main/java/com/vanta/vanta_auditor_api/SDKConfiguration.java @@ -16,8 +16,8 @@ public class SDKConfiguration { private static final String LANGUAGE = "java"; public static final String OPENAPI_DOC_VERSION = "1.0.0"; - public static final String SDK_VERSION = "0.3.0"; - public static final String GEN_VERSION = "2.658.3"; + public static final String SDK_VERSION = "0.4.0"; + public static final String GEN_VERSION = "2.684.0"; private static final String BASE_PACKAGE = "com.vanta.vanta_auditor_api"; public static final String USER_AGENT = String.format("speakeasy-sdk/%s %s %s %s %s", @@ -96,7 +96,7 @@ public void setHooks(Hooks hooks) { this._hooks = hooks; } - /** + /** * Initializes state (for example hooks). **/ public void initialize() { diff --git a/src/main/java/com/vanta/vanta_auditor_api/models/errors/APIException.java b/src/main/java/com/vanta/vanta_auditor_api/models/errors/APIException.java index 5180a2b..a07df81 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/models/errors/APIException.java +++ b/src/main/java/com/vanta/vanta_auditor_api/models/errors/APIException.java @@ -62,10 +62,12 @@ public int hashCode() { @Override public String toString() { return Utils.toString(APIException.class, - "rawResponse", rawResponse, + "requestMethod", rawResponse.request().method(), + "requestUri", rawResponse.request().uri(), "code", code, + "responseHeaders", rawResponse.headers().map(), "message", message, - "body", body); + "body", bodyAsString()); } public HttpResponse rawResponse() { diff --git a/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateAuditorRequestBuilder.java b/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateAuditorRequestBuilder.java index d65e7de..49b6901 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateAuditorRequestBuilder.java +++ b/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateAuditorRequestBuilder.java @@ -7,7 +7,7 @@ import com.vanta.vanta_auditor_api.SDKConfiguration; import com.vanta.vanta_auditor_api.models.components.AddAuditorInput; -import com.vanta.vanta_auditor_api.operations.CreateAuditorOperation; +import com.vanta.vanta_auditor_api.operations.CreateAuditor; import com.vanta.vanta_auditor_api.utils.Utils; import java.lang.Exception; @@ -29,7 +29,7 @@ public CreateAuditorRequestBuilder request(AddAuditorInput request) { public CreateAuditorResponse call() throws Exception { RequestOperation operation - = new CreateAuditorOperation(sdkConfiguration); + = new CreateAuditor.Sync(sdkConfiguration); return operation.handleResponse(operation.doRequest(request)); } diff --git a/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCommentForAuditEvidenceRequestBuilder.java b/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCommentForAuditEvidenceRequestBuilder.java index c9c5f2e..45e4399 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCommentForAuditEvidenceRequestBuilder.java +++ b/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCommentForAuditEvidenceRequestBuilder.java @@ -7,7 +7,7 @@ import com.vanta.vanta_auditor_api.SDKConfiguration; import com.vanta.vanta_auditor_api.models.components.AddCommentInput; -import com.vanta.vanta_auditor_api.operations.CreateCommentForAuditEvidenceOperation; +import com.vanta.vanta_auditor_api.operations.CreateCommentForAuditEvidence; import com.vanta.vanta_auditor_api.utils.Utils; import java.lang.Exception; import java.lang.String; @@ -54,7 +54,7 @@ private CreateCommentForAuditEvidenceRequest buildRequest() { public CreateCommentForAuditEvidenceResponse call() throws Exception { RequestOperation operation - = new CreateCommentForAuditEvidenceOperation(sdkConfiguration); + = new CreateCommentForAuditEvidence.Sync(sdkConfiguration); CreateCommentForAuditEvidenceRequest request = buildRequest(); return operation.handleResponse(operation.doRequest(request)); diff --git a/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCustomControlRequestBuilder.java b/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCustomControlRequestBuilder.java index 84cd3fa..cceaff0 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCustomControlRequestBuilder.java +++ b/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCustomControlRequestBuilder.java @@ -7,7 +7,7 @@ import com.vanta.vanta_auditor_api.SDKConfiguration; import com.vanta.vanta_auditor_api.models.components.CreateCustomControlInput; -import com.vanta.vanta_auditor_api.operations.CreateCustomControlOperation; +import com.vanta.vanta_auditor_api.operations.CreateCustomControl; import com.vanta.vanta_auditor_api.utils.Utils; import java.lang.Exception; import java.lang.String; @@ -46,7 +46,7 @@ private CreateCustomControlRequest buildRequest() { public CreateCustomControlResponse call() throws Exception { RequestOperation operation - = new CreateCustomControlOperation(sdkConfiguration); + = new CreateCustomControl.Sync(sdkConfiguration); CreateCustomControlRequest request = buildRequest(); return operation.handleResponse(operation.doRequest(request)); diff --git a/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCustomEvidenceRequestRequestBuilder.java b/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCustomEvidenceRequestRequestBuilder.java index 09a5c2a..56a007a 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCustomEvidenceRequestRequestBuilder.java +++ b/src/main/java/com/vanta/vanta_auditor_api/models/operations/CreateCustomEvidenceRequestRequestBuilder.java @@ -7,7 +7,7 @@ import com.vanta.vanta_auditor_api.SDKConfiguration; import com.vanta.vanta_auditor_api.models.components.CreateCustomEvidenceRequestInput; -import com.vanta.vanta_auditor_api.operations.CreateCustomEvidenceRequestOperation; +import com.vanta.vanta_auditor_api.operations.CreateCustomEvidenceRequest; import com.vanta.vanta_auditor_api.utils.Utils; import java.lang.Exception; import java.lang.String; @@ -46,7 +46,7 @@ private CreateCustomEvidenceRequestRequest buildRequest() { public CreateCustomEvidenceRequestResponse call() throws Exception { RequestOperation operation - = new CreateCustomEvidenceRequestOperation(sdkConfiguration); + = new CreateCustomEvidenceRequest.Sync(sdkConfiguration); CreateCustomEvidenceRequestRequest request = buildRequest(); return operation.handleResponse(operation.doRequest(request)); diff --git a/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditCommentsRequestBuilder.java b/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditCommentsRequestBuilder.java index 09bee16..b303ea1 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditCommentsRequestBuilder.java +++ b/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditCommentsRequestBuilder.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.operations.ListAuditCommentsOperation; +import com.vanta.vanta_auditor_api.operations.ListAuditComments; import com.vanta.vanta_auditor_api.utils.LazySingletonValue; import com.vanta.vanta_auditor_api.utils.Utils; import java.lang.Exception; @@ -90,7 +90,7 @@ private ListAuditCommentsRequest buildRequest() { public ListAuditCommentsResponse call() throws Exception { RequestOperation operation - = new ListAuditCommentsOperation(sdkConfiguration); + = new ListAuditComments.Sync(sdkConfiguration); ListAuditCommentsRequest request = buildRequest(); return operation.handleResponse(operation.doRequest(request)); diff --git a/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditControlsRequestBuilder.java b/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditControlsRequestBuilder.java index 0f701b8..b9b1e8a 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditControlsRequestBuilder.java +++ b/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditControlsRequestBuilder.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.operations.ListAuditControlsOperation; +import com.vanta.vanta_auditor_api.operations.ListAuditControls; import com.vanta.vanta_auditor_api.utils.LazySingletonValue; import com.vanta.vanta_auditor_api.utils.Utils; import java.lang.Exception; @@ -75,7 +75,7 @@ private ListAuditControlsRequest buildRequest() { public ListAuditControlsResponse call() throws Exception { RequestOperation operation - = new ListAuditControlsOperation(sdkConfiguration); + = new ListAuditControls.Sync(sdkConfiguration); ListAuditControlsRequest request = buildRequest(); return operation.handleResponse(operation.doRequest(request)); diff --git a/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditEvidenceRequestBuilder.java b/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditEvidenceRequestBuilder.java index 6a8b800..1aa1952 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditEvidenceRequestBuilder.java +++ b/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditEvidenceRequestBuilder.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.operations.ListAuditEvidenceOperation; +import com.vanta.vanta_auditor_api.operations.ListAuditEvidence; import com.vanta.vanta_auditor_api.utils.LazySingletonValue; import com.vanta.vanta_auditor_api.utils.Utils; import java.lang.Exception; @@ -90,7 +90,7 @@ private ListAuditEvidenceRequest buildRequest() { public ListAuditEvidenceResponse call() throws Exception { RequestOperation operation - = new ListAuditEvidenceOperation(sdkConfiguration); + = new ListAuditEvidence.Sync(sdkConfiguration); ListAuditEvidenceRequest request = buildRequest(); return operation.handleResponse(operation.doRequest(request)); diff --git a/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditEvidenceUrlsRequestBuilder.java b/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditEvidenceUrlsRequestBuilder.java index 96b5a11..09d0898 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditEvidenceUrlsRequestBuilder.java +++ b/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditEvidenceUrlsRequestBuilder.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.operations.ListAuditEvidenceUrlsOperation; +import com.vanta.vanta_auditor_api.operations.ListAuditEvidenceUrls; import com.vanta.vanta_auditor_api.utils.LazySingletonValue; import com.vanta.vanta_auditor_api.utils.Utils; import java.lang.Exception; @@ -83,7 +83,7 @@ private ListAuditEvidenceUrlsRequest buildRequest() { public ListAuditEvidenceUrlsResponse call() throws Exception { RequestOperation operation - = new ListAuditEvidenceUrlsOperation(sdkConfiguration); + = new ListAuditEvidenceUrls.Sync(sdkConfiguration); ListAuditEvidenceUrlsRequest request = buildRequest(); return operation.handleResponse(operation.doRequest(request)); diff --git a/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditsRequestBuilder.java b/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditsRequestBuilder.java index 6871097..2604c2f 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditsRequestBuilder.java +++ b/src/main/java/com/vanta/vanta_auditor_api/models/operations/ListAuditsRequestBuilder.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.operations.ListAuditsOperation; +import com.vanta.vanta_auditor_api.operations.ListAudits; import com.vanta.vanta_auditor_api.utils.LazySingletonValue; import com.vanta.vanta_auditor_api.utils.Utils; import java.lang.Boolean; @@ -97,7 +97,7 @@ private ListAuditsRequest buildRequest() { public ListAuditsResponse call() throws Exception { RequestOperation operation - = new ListAuditsOperation(sdkConfiguration); + = new ListAudits.Sync(sdkConfiguration); ListAuditsRequest request = buildRequest(); return operation.handleResponse(operation.doRequest(request)); diff --git a/src/main/java/com/vanta/vanta_auditor_api/models/operations/UpdateAuditEvidenceRequestBuilder.java b/src/main/java/com/vanta/vanta_auditor_api/models/operations/UpdateAuditEvidenceRequestBuilder.java index d0e162a..fd12552 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/models/operations/UpdateAuditEvidenceRequestBuilder.java +++ b/src/main/java/com/vanta/vanta_auditor_api/models/operations/UpdateAuditEvidenceRequestBuilder.java @@ -7,7 +7,7 @@ import com.vanta.vanta_auditor_api.SDKConfiguration; import com.vanta.vanta_auditor_api.models.components.AuditEvidenceUpdateInput; -import com.vanta.vanta_auditor_api.operations.UpdateAuditEvidenceOperation; +import com.vanta.vanta_auditor_api.operations.UpdateAuditEvidence; import com.vanta.vanta_auditor_api.utils.Utils; import java.lang.Exception; import java.lang.String; @@ -54,7 +54,7 @@ private UpdateAuditEvidenceRequest buildRequest() { public UpdateAuditEvidenceResponse call() throws Exception { RequestOperation operation - = new UpdateAuditEvidenceOperation(sdkConfiguration); + = new UpdateAuditEvidence.Sync(sdkConfiguration); UpdateAuditEvidenceRequest request = buildRequest(); return operation.handleResponse(operation.doRequest(request)); diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateAuditor.java b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateAuditor.java new file mode 100644 index 0000000..407665f --- /dev/null +++ b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateAuditor.java @@ -0,0 +1,204 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.vanta.vanta_auditor_api.operations; + +import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.vanta.vanta_auditor_api.SDKConfiguration; +import com.vanta.vanta_auditor_api.SecuritySource; +import com.vanta.vanta_auditor_api.models.components.AddAuditorInput; +import com.vanta.vanta_auditor_api.models.components.Auditor; +import com.vanta.vanta_auditor_api.models.errors.APIException; +import com.vanta.vanta_auditor_api.models.operations.CreateAuditorResponse; +import com.vanta.vanta_auditor_api.utils.HTTPClient; +import com.vanta.vanta_auditor_api.utils.HTTPRequest; +import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; +import com.vanta.vanta_auditor_api.utils.SerializedBody; +import com.vanta.vanta_auditor_api.utils.Utils.JsonShape; +import com.vanta.vanta_auditor_api.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.Object; +import java.lang.String; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; + + + +public class CreateAuditor { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final HTTPClient client; + + public Base(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + this.client = this.sdkConfiguration.client(); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateAuditor", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateAuditor", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateAuditor", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + HttpRequest buildRequest(AddAuditorInput request) throws Exception { + String url = Utils.generateURL( + this.baseUrl, + "/auditors"); + HTTPRequest req = new HTTPRequest(url, "POST"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + new TypeReference() { + }); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "request", + "json", + false); + if (serializedRequestBody == null) { + throw new Exception("Request body is required"); + } + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync(SDKConfiguration sdkConfiguration) { + super(sdkConfiguration); + } + + private HttpRequest onBuildRequest(AddAuditorInput request) throws Exception { + HttpRequest req = buildRequest(request); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(AddAuditorInput request) throws Exception { + HttpRequest r = onBuildRequest(request); + HttpResponse httpRes; + try { + httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + httpRes = onError(httpRes, null); + } else { + httpRes = onSuccess(httpRes); + } + } catch (Exception e) { + httpRes = onError(null, e); + } + + return httpRes; + } + + + @Override + public CreateAuditorResponse handleResponse(HttpResponse response) throws Exception { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + CreateAuditorResponse.Builder resBuilder = + CreateAuditorResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + CreateAuditorResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + Auditor out = Utils.mapper().readValue( + response.body(), + new TypeReference<>() { + }); + res.withAuditor(out); + return res; + } else { + throw new APIException( + response, + response.statusCode(), + "Unexpected content-type received: " + contentType, + Utils.extractByteArrayFromBody(response)); + } + } + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + throw new APIException( + response, + response.statusCode(), + "Unexpected status code received: " + response.statusCode(), + Utils.extractByteArrayFromBody(response)); + } + } +} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateAuditorOperation.java b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateAuditorOperation.java deleted file mode 100644 index 1170e95..0000000 --- a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateAuditorOperation.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -package com.vanta.vanta_auditor_api.operations; - -import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.SecuritySource; -import com.vanta.vanta_auditor_api.models.components.AddAuditorInput; -import com.vanta.vanta_auditor_api.models.components.Auditor; -import com.vanta.vanta_auditor_api.models.errors.APIException; -import com.vanta.vanta_auditor_api.models.operations.CreateAuditorResponse; -import com.vanta.vanta_auditor_api.utils.HTTPClient; -import com.vanta.vanta_auditor_api.utils.HTTPRequest; -import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; -import com.vanta.vanta_auditor_api.utils.SerializedBody; -import com.vanta.vanta_auditor_api.utils.Utils.JsonShape; -import com.vanta.vanta_auditor_api.utils.Utils; -import java.io.InputStream; -import java.lang.Exception; -import java.lang.Object; -import java.lang.String; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.Optional; - - -public class CreateAuditorOperation implements RequestOperation { - - private final SDKConfiguration sdkConfiguration; - private final String baseUrl; - private final SecuritySource securitySource; - private final HTTPClient client; - - public CreateAuditorOperation(SDKConfiguration sdkConfiguration) { - this.sdkConfiguration = sdkConfiguration; - this.baseUrl = this.sdkConfiguration.serverUrl(); - this.securitySource = this.sdkConfiguration.securitySource(); - this.client = this.sdkConfiguration.client(); - } - - private Optional securitySource() { - return Optional.ofNullable(this.securitySource); - } - - public HttpRequest buildRequest(AddAuditorInput request) throws Exception { - String url = Utils.generateURL( - this.baseUrl, - "/auditors"); - HTTPRequest req = new HTTPRequest(url, "POST"); - Object convertedRequest = Utils.convertToShape( - request, - JsonShape.DEFAULT, - new TypeReference() {}); - SerializedBody serializedRequestBody = Utils.serializeRequestBody( - convertedRequest, - "request", - "json", - false); - if (serializedRequestBody == null) { - throw new Exception("Request body is required"); - } - req.setBody(Optional.ofNullable(serializedRequestBody)); - req.addHeader("Accept", "application/json") - .addHeader("user-agent", SDKConfiguration.USER_AGENT); - Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); - - return sdkConfiguration.hooks().beforeRequest( - new BeforeRequestContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateAuditor", - java.util.Optional.of(java.util.List.of()), - securitySource()), - req.build()); - } - - private HttpResponse onError(HttpResponse response, - Exception error) throws Exception { - return sdkConfiguration.hooks() - .afterError( - new AfterErrorContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateAuditor", - java.util.Optional.of(java.util.List.of()), - securitySource()), - Optional.ofNullable(response), - Optional.ofNullable(error)); - } - - private HttpResponse onSuccess(HttpResponse response) throws Exception { - return sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateAuditor", - java.util.Optional.of(java.util.List.of()), - securitySource()), - response); - } - - @Override - public HttpResponse doRequest(AddAuditorInput request) throws Exception { - HttpRequest r = buildRequest(request); - HttpResponse httpRes; - try { - httpRes = client.send(r); - if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { - httpRes = onError(httpRes, null); - } else { - httpRes = onSuccess(httpRes); - } - } catch (Exception e) { - httpRes = onError(null, e); - } - - return httpRes; - } - - - @Override - public CreateAuditorResponse handleResponse(HttpResponse response) throws Exception { - String contentType = response - .headers() - .firstValue("Content-Type") - .orElse("application/octet-stream"); - CreateAuditorResponse.Builder resBuilder = - CreateAuditorResponse - .builder() - .contentType(contentType) - .statusCode(response.statusCode()) - .rawResponse(response); - - CreateAuditorResponse res = resBuilder.build(); - - if (Utils.statusCodeMatches(response.statusCode(), "200")) { - if (Utils.contentTypeMatches(contentType, "application/json")) { - Auditor out = Utils.mapper().readValue( - response.body(), - new TypeReference<>() { - }); - res.withAuditor(out); - return res; - } else { - throw new APIException( - response, - response.statusCode(), - "Unexpected content-type received: " + contentType, - Utils.extractByteArrayFromBody(response)); - } - } - if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - throw new APIException( - response, - response.statusCode(), - "Unexpected status code received: " + response.statusCode(), - Utils.extractByteArrayFromBody(response)); - } -} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCommentForAuditEvidence.java b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCommentForAuditEvidence.java new file mode 100644 index 0000000..810f509 --- /dev/null +++ b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCommentForAuditEvidence.java @@ -0,0 +1,206 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.vanta.vanta_auditor_api.operations; + +import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.vanta.vanta_auditor_api.SDKConfiguration; +import com.vanta.vanta_auditor_api.SecuritySource; +import com.vanta.vanta_auditor_api.models.components.Comment; +import com.vanta.vanta_auditor_api.models.errors.APIException; +import com.vanta.vanta_auditor_api.models.operations.CreateCommentForAuditEvidenceRequest; +import com.vanta.vanta_auditor_api.models.operations.CreateCommentForAuditEvidenceResponse; +import com.vanta.vanta_auditor_api.utils.HTTPClient; +import com.vanta.vanta_auditor_api.utils.HTTPRequest; +import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; +import com.vanta.vanta_auditor_api.utils.SerializedBody; +import com.vanta.vanta_auditor_api.utils.Utils.JsonShape; +import com.vanta.vanta_auditor_api.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.Object; +import java.lang.String; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; + + + +public class CreateCommentForAuditEvidence { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final HTTPClient client; + + public Base(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + this.client = this.sdkConfiguration.client(); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateCommentForAuditEvidence", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateCommentForAuditEvidence", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateCommentForAuditEvidence", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + HttpRequest buildRequest(CreateCommentForAuditEvidenceRequest request) throws Exception { + String url = Utils.generateURL( + CreateCommentForAuditEvidenceRequest.class, + this.baseUrl, + "/audits/{auditId}/evidence/{auditEvidenceId}/comments", + request, null); + HTTPRequest req = new HTTPRequest(url, "POST"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + new TypeReference() { + }); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "addCommentInput", + "json", + false); + if (serializedRequestBody == null) { + throw new Exception("Request body is required"); + } + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync(SDKConfiguration sdkConfiguration) { + super(sdkConfiguration); + } + + private HttpRequest onBuildRequest(CreateCommentForAuditEvidenceRequest request) throws Exception { + HttpRequest req = buildRequest(request); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(CreateCommentForAuditEvidenceRequest request) throws Exception { + HttpRequest r = onBuildRequest(request); + HttpResponse httpRes; + try { + httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + httpRes = onError(httpRes, null); + } else { + httpRes = onSuccess(httpRes); + } + } catch (Exception e) { + httpRes = onError(null, e); + } + + return httpRes; + } + + + @Override + public CreateCommentForAuditEvidenceResponse handleResponse(HttpResponse response) throws Exception { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + CreateCommentForAuditEvidenceResponse.Builder resBuilder = + CreateCommentForAuditEvidenceResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + CreateCommentForAuditEvidenceResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + Comment out = Utils.mapper().readValue( + response.body(), + new TypeReference<>() { + }); + res.withComment(out); + return res; + } else { + throw new APIException( + response, + response.statusCode(), + "Unexpected content-type received: " + contentType, + Utils.extractByteArrayFromBody(response)); + } + } + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + throw new APIException( + response, + response.statusCode(), + "Unexpected status code received: " + response.statusCode(), + Utils.extractByteArrayFromBody(response)); + } + } +} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCommentForAuditEvidenceOperation.java b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCommentForAuditEvidenceOperation.java deleted file mode 100644 index fa58209..0000000 --- a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCommentForAuditEvidenceOperation.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -package com.vanta.vanta_auditor_api.operations; - -import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.SecuritySource; -import com.vanta.vanta_auditor_api.models.components.Comment; -import com.vanta.vanta_auditor_api.models.errors.APIException; -import com.vanta.vanta_auditor_api.models.operations.CreateCommentForAuditEvidenceRequest; -import com.vanta.vanta_auditor_api.models.operations.CreateCommentForAuditEvidenceResponse; -import com.vanta.vanta_auditor_api.utils.HTTPClient; -import com.vanta.vanta_auditor_api.utils.HTTPRequest; -import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; -import com.vanta.vanta_auditor_api.utils.SerializedBody; -import com.vanta.vanta_auditor_api.utils.Utils.JsonShape; -import com.vanta.vanta_auditor_api.utils.Utils; -import java.io.InputStream; -import java.lang.Exception; -import java.lang.Object; -import java.lang.String; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.Optional; - - -public class CreateCommentForAuditEvidenceOperation implements RequestOperation { - - private final SDKConfiguration sdkConfiguration; - private final String baseUrl; - private final SecuritySource securitySource; - private final HTTPClient client; - - public CreateCommentForAuditEvidenceOperation(SDKConfiguration sdkConfiguration) { - this.sdkConfiguration = sdkConfiguration; - this.baseUrl = this.sdkConfiguration.serverUrl(); - this.securitySource = this.sdkConfiguration.securitySource(); - this.client = this.sdkConfiguration.client(); - } - - private Optional securitySource() { - return Optional.ofNullable(this.securitySource); - } - - public HttpRequest buildRequest(CreateCommentForAuditEvidenceRequest request) throws Exception { - String url = Utils.generateURL( - CreateCommentForAuditEvidenceRequest.class, - this.baseUrl, - "/audits/{auditId}/evidence/{auditEvidenceId}/comments", - request, null); - HTTPRequest req = new HTTPRequest(url, "POST"); - Object convertedRequest = Utils.convertToShape( - request, - JsonShape.DEFAULT, - new TypeReference() {}); - SerializedBody serializedRequestBody = Utils.serializeRequestBody( - convertedRequest, - "addCommentInput", - "json", - false); - if (serializedRequestBody == null) { - throw new Exception("Request body is required"); - } - req.setBody(Optional.ofNullable(serializedRequestBody)); - req.addHeader("Accept", "application/json") - .addHeader("user-agent", SDKConfiguration.USER_AGENT); - Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); - - return sdkConfiguration.hooks().beforeRequest( - new BeforeRequestContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateCommentForAuditEvidence", - java.util.Optional.of(java.util.List.of()), - securitySource()), - req.build()); - } - - private HttpResponse onError(HttpResponse response, - Exception error) throws Exception { - return sdkConfiguration.hooks() - .afterError( - new AfterErrorContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateCommentForAuditEvidence", - java.util.Optional.of(java.util.List.of()), - securitySource()), - Optional.ofNullable(response), - Optional.ofNullable(error)); - } - - private HttpResponse onSuccess(HttpResponse response) throws Exception { - return sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateCommentForAuditEvidence", - java.util.Optional.of(java.util.List.of()), - securitySource()), - response); - } - - @Override - public HttpResponse doRequest(CreateCommentForAuditEvidenceRequest request) throws Exception { - HttpRequest r = buildRequest(request); - HttpResponse httpRes; - try { - httpRes = client.send(r); - if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { - httpRes = onError(httpRes, null); - } else { - httpRes = onSuccess(httpRes); - } - } catch (Exception e) { - httpRes = onError(null, e); - } - - return httpRes; - } - - - @Override - public CreateCommentForAuditEvidenceResponse handleResponse(HttpResponse response) throws Exception { - String contentType = response - .headers() - .firstValue("Content-Type") - .orElse("application/octet-stream"); - CreateCommentForAuditEvidenceResponse.Builder resBuilder = - CreateCommentForAuditEvidenceResponse - .builder() - .contentType(contentType) - .statusCode(response.statusCode()) - .rawResponse(response); - - CreateCommentForAuditEvidenceResponse res = resBuilder.build(); - - if (Utils.statusCodeMatches(response.statusCode(), "200")) { - if (Utils.contentTypeMatches(contentType, "application/json")) { - Comment out = Utils.mapper().readValue( - response.body(), - new TypeReference<>() { - }); - res.withComment(out); - return res; - } else { - throw new APIException( - response, - response.statusCode(), - "Unexpected content-type received: " + contentType, - Utils.extractByteArrayFromBody(response)); - } - } - if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - throw new APIException( - response, - response.statusCode(), - "Unexpected status code received: " + response.statusCode(), - Utils.extractByteArrayFromBody(response)); - } -} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomControl.java b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomControl.java new file mode 100644 index 0000000..e4bf8c2 --- /dev/null +++ b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomControl.java @@ -0,0 +1,206 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.vanta.vanta_auditor_api.operations; + +import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.vanta.vanta_auditor_api.SDKConfiguration; +import com.vanta.vanta_auditor_api.SecuritySource; +import com.vanta.vanta_auditor_api.models.components.Control; +import com.vanta.vanta_auditor_api.models.errors.APIException; +import com.vanta.vanta_auditor_api.models.operations.CreateCustomControlRequest; +import com.vanta.vanta_auditor_api.models.operations.CreateCustomControlResponse; +import com.vanta.vanta_auditor_api.utils.HTTPClient; +import com.vanta.vanta_auditor_api.utils.HTTPRequest; +import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; +import com.vanta.vanta_auditor_api.utils.SerializedBody; +import com.vanta.vanta_auditor_api.utils.Utils.JsonShape; +import com.vanta.vanta_auditor_api.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.Object; +import java.lang.String; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; + + + +public class CreateCustomControl { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final HTTPClient client; + + public Base(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + this.client = this.sdkConfiguration.client(); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateCustomControl", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateCustomControl", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateCustomControl", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + HttpRequest buildRequest(CreateCustomControlRequest request) throws Exception { + String url = Utils.generateURL( + CreateCustomControlRequest.class, + this.baseUrl, + "/audits/{auditId}/controls/custom-controls", + request, null); + HTTPRequest req = new HTTPRequest(url, "POST"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + new TypeReference() { + }); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "createCustomControlInput", + "json", + false); + if (serializedRequestBody == null) { + throw new Exception("Request body is required"); + } + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync(SDKConfiguration sdkConfiguration) { + super(sdkConfiguration); + } + + private HttpRequest onBuildRequest(CreateCustomControlRequest request) throws Exception { + HttpRequest req = buildRequest(request); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(CreateCustomControlRequest request) throws Exception { + HttpRequest r = onBuildRequest(request); + HttpResponse httpRes; + try { + httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + httpRes = onError(httpRes, null); + } else { + httpRes = onSuccess(httpRes); + } + } catch (Exception e) { + httpRes = onError(null, e); + } + + return httpRes; + } + + + @Override + public CreateCustomControlResponse handleResponse(HttpResponse response) throws Exception { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + CreateCustomControlResponse.Builder resBuilder = + CreateCustomControlResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + CreateCustomControlResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "201")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + Control out = Utils.mapper().readValue( + response.body(), + new TypeReference<>() { + }); + res.withControl(out); + return res; + } else { + throw new APIException( + response, + response.statusCode(), + "Unexpected content-type received: " + contentType, + Utils.extractByteArrayFromBody(response)); + } + } + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + throw new APIException( + response, + response.statusCode(), + "Unexpected status code received: " + response.statusCode(), + Utils.extractByteArrayFromBody(response)); + } + } +} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomControlOperation.java b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomControlOperation.java deleted file mode 100644 index 02c37b0..0000000 --- a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomControlOperation.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -package com.vanta.vanta_auditor_api.operations; - -import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.SecuritySource; -import com.vanta.vanta_auditor_api.models.components.Control; -import com.vanta.vanta_auditor_api.models.errors.APIException; -import com.vanta.vanta_auditor_api.models.operations.CreateCustomControlRequest; -import com.vanta.vanta_auditor_api.models.operations.CreateCustomControlResponse; -import com.vanta.vanta_auditor_api.utils.HTTPClient; -import com.vanta.vanta_auditor_api.utils.HTTPRequest; -import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; -import com.vanta.vanta_auditor_api.utils.SerializedBody; -import com.vanta.vanta_auditor_api.utils.Utils.JsonShape; -import com.vanta.vanta_auditor_api.utils.Utils; -import java.io.InputStream; -import java.lang.Exception; -import java.lang.Object; -import java.lang.String; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.Optional; - - -public class CreateCustomControlOperation implements RequestOperation { - - private final SDKConfiguration sdkConfiguration; - private final String baseUrl; - private final SecuritySource securitySource; - private final HTTPClient client; - - public CreateCustomControlOperation(SDKConfiguration sdkConfiguration) { - this.sdkConfiguration = sdkConfiguration; - this.baseUrl = this.sdkConfiguration.serverUrl(); - this.securitySource = this.sdkConfiguration.securitySource(); - this.client = this.sdkConfiguration.client(); - } - - private Optional securitySource() { - return Optional.ofNullable(this.securitySource); - } - - public HttpRequest buildRequest(CreateCustomControlRequest request) throws Exception { - String url = Utils.generateURL( - CreateCustomControlRequest.class, - this.baseUrl, - "/audits/{auditId}/controls/custom-controls", - request, null); - HTTPRequest req = new HTTPRequest(url, "POST"); - Object convertedRequest = Utils.convertToShape( - request, - JsonShape.DEFAULT, - new TypeReference() {}); - SerializedBody serializedRequestBody = Utils.serializeRequestBody( - convertedRequest, - "createCustomControlInput", - "json", - false); - if (serializedRequestBody == null) { - throw new Exception("Request body is required"); - } - req.setBody(Optional.ofNullable(serializedRequestBody)); - req.addHeader("Accept", "application/json") - .addHeader("user-agent", SDKConfiguration.USER_AGENT); - Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); - - return sdkConfiguration.hooks().beforeRequest( - new BeforeRequestContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateCustomControl", - java.util.Optional.of(java.util.List.of()), - securitySource()), - req.build()); - } - - private HttpResponse onError(HttpResponse response, - Exception error) throws Exception { - return sdkConfiguration.hooks() - .afterError( - new AfterErrorContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateCustomControl", - java.util.Optional.of(java.util.List.of()), - securitySource()), - Optional.ofNullable(response), - Optional.ofNullable(error)); - } - - private HttpResponse onSuccess(HttpResponse response) throws Exception { - return sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateCustomControl", - java.util.Optional.of(java.util.List.of()), - securitySource()), - response); - } - - @Override - public HttpResponse doRequest(CreateCustomControlRequest request) throws Exception { - HttpRequest r = buildRequest(request); - HttpResponse httpRes; - try { - httpRes = client.send(r); - if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { - httpRes = onError(httpRes, null); - } else { - httpRes = onSuccess(httpRes); - } - } catch (Exception e) { - httpRes = onError(null, e); - } - - return httpRes; - } - - - @Override - public CreateCustomControlResponse handleResponse(HttpResponse response) throws Exception { - String contentType = response - .headers() - .firstValue("Content-Type") - .orElse("application/octet-stream"); - CreateCustomControlResponse.Builder resBuilder = - CreateCustomControlResponse - .builder() - .contentType(contentType) - .statusCode(response.statusCode()) - .rawResponse(response); - - CreateCustomControlResponse res = resBuilder.build(); - - if (Utils.statusCodeMatches(response.statusCode(), "201")) { - if (Utils.contentTypeMatches(contentType, "application/json")) { - Control out = Utils.mapper().readValue( - response.body(), - new TypeReference<>() { - }); - res.withControl(out); - return res; - } else { - throw new APIException( - response, - response.statusCode(), - "Unexpected content-type received: " + contentType, - Utils.extractByteArrayFromBody(response)); - } - } - if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - throw new APIException( - response, - response.statusCode(), - "Unexpected status code received: " + response.statusCode(), - Utils.extractByteArrayFromBody(response)); - } -} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomEvidenceRequest.java b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomEvidenceRequest.java new file mode 100644 index 0000000..cc6197a --- /dev/null +++ b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomEvidenceRequest.java @@ -0,0 +1,206 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.vanta.vanta_auditor_api.operations; + +import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.vanta.vanta_auditor_api.SDKConfiguration; +import com.vanta.vanta_auditor_api.SecuritySource; +import com.vanta.vanta_auditor_api.models.components.CustomEvidenceRequest; +import com.vanta.vanta_auditor_api.models.errors.APIException; +import com.vanta.vanta_auditor_api.models.operations.CreateCustomEvidenceRequestRequest; +import com.vanta.vanta_auditor_api.models.operations.CreateCustomEvidenceRequestResponse; +import com.vanta.vanta_auditor_api.utils.HTTPClient; +import com.vanta.vanta_auditor_api.utils.HTTPRequest; +import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; +import com.vanta.vanta_auditor_api.utils.SerializedBody; +import com.vanta.vanta_auditor_api.utils.Utils.JsonShape; +import com.vanta.vanta_auditor_api.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.Object; +import java.lang.String; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; + + + +public class CreateCustomEvidenceRequest { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final HTTPClient client; + + public Base(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + this.client = this.sdkConfiguration.client(); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateCustomEvidenceRequest", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateCustomEvidenceRequest", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateCustomEvidenceRequest", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + HttpRequest buildRequest(CreateCustomEvidenceRequestRequest request) throws Exception { + String url = Utils.generateURL( + CreateCustomEvidenceRequestRequest.class, + this.baseUrl, + "/audits/{auditId}/evidence/custom-evidence-requests", + request, null); + HTTPRequest req = new HTTPRequest(url, "POST"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + new TypeReference() { + }); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "createCustomEvidenceRequestInput", + "json", + false); + if (serializedRequestBody == null) { + throw new Exception("Request body is required"); + } + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync(SDKConfiguration sdkConfiguration) { + super(sdkConfiguration); + } + + private HttpRequest onBuildRequest(CreateCustomEvidenceRequestRequest request) throws Exception { + HttpRequest req = buildRequest(request); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(CreateCustomEvidenceRequestRequest request) throws Exception { + HttpRequest r = onBuildRequest(request); + HttpResponse httpRes; + try { + httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + httpRes = onError(httpRes, null); + } else { + httpRes = onSuccess(httpRes); + } + } catch (Exception e) { + httpRes = onError(null, e); + } + + return httpRes; + } + + + @Override + public CreateCustomEvidenceRequestResponse handleResponse(HttpResponse response) throws Exception { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + CreateCustomEvidenceRequestResponse.Builder resBuilder = + CreateCustomEvidenceRequestResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + CreateCustomEvidenceRequestResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + CustomEvidenceRequest out = Utils.mapper().readValue( + response.body(), + new TypeReference<>() { + }); + res.withCustomEvidenceRequest(out); + return res; + } else { + throw new APIException( + response, + response.statusCode(), + "Unexpected content-type received: " + contentType, + Utils.extractByteArrayFromBody(response)); + } + } + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + throw new APIException( + response, + response.statusCode(), + "Unexpected status code received: " + response.statusCode(), + Utils.extractByteArrayFromBody(response)); + } + } +} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomEvidenceRequestOperation.java b/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomEvidenceRequestOperation.java deleted file mode 100644 index f22072e..0000000 --- a/src/main/java/com/vanta/vanta_auditor_api/operations/CreateCustomEvidenceRequestOperation.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -package com.vanta.vanta_auditor_api.operations; - -import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.SecuritySource; -import com.vanta.vanta_auditor_api.models.components.CustomEvidenceRequest; -import com.vanta.vanta_auditor_api.models.errors.APIException; -import com.vanta.vanta_auditor_api.models.operations.CreateCustomEvidenceRequestRequest; -import com.vanta.vanta_auditor_api.models.operations.CreateCustomEvidenceRequestResponse; -import com.vanta.vanta_auditor_api.utils.HTTPClient; -import com.vanta.vanta_auditor_api.utils.HTTPRequest; -import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; -import com.vanta.vanta_auditor_api.utils.SerializedBody; -import com.vanta.vanta_auditor_api.utils.Utils.JsonShape; -import com.vanta.vanta_auditor_api.utils.Utils; -import java.io.InputStream; -import java.lang.Exception; -import java.lang.Object; -import java.lang.String; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.Optional; - - -public class CreateCustomEvidenceRequestOperation implements RequestOperation { - - private final SDKConfiguration sdkConfiguration; - private final String baseUrl; - private final SecuritySource securitySource; - private final HTTPClient client; - - public CreateCustomEvidenceRequestOperation(SDKConfiguration sdkConfiguration) { - this.sdkConfiguration = sdkConfiguration; - this.baseUrl = this.sdkConfiguration.serverUrl(); - this.securitySource = this.sdkConfiguration.securitySource(); - this.client = this.sdkConfiguration.client(); - } - - private Optional securitySource() { - return Optional.ofNullable(this.securitySource); - } - - public HttpRequest buildRequest(CreateCustomEvidenceRequestRequest request) throws Exception { - String url = Utils.generateURL( - CreateCustomEvidenceRequestRequest.class, - this.baseUrl, - "/audits/{auditId}/evidence/custom-evidence-requests", - request, null); - HTTPRequest req = new HTTPRequest(url, "POST"); - Object convertedRequest = Utils.convertToShape( - request, - JsonShape.DEFAULT, - new TypeReference() {}); - SerializedBody serializedRequestBody = Utils.serializeRequestBody( - convertedRequest, - "createCustomEvidenceRequestInput", - "json", - false); - if (serializedRequestBody == null) { - throw new Exception("Request body is required"); - } - req.setBody(Optional.ofNullable(serializedRequestBody)); - req.addHeader("Accept", "application/json") - .addHeader("user-agent", SDKConfiguration.USER_AGENT); - Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); - - return sdkConfiguration.hooks().beforeRequest( - new BeforeRequestContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateCustomEvidenceRequest", - java.util.Optional.of(java.util.List.of()), - securitySource()), - req.build()); - } - - private HttpResponse onError(HttpResponse response, - Exception error) throws Exception { - return sdkConfiguration.hooks() - .afterError( - new AfterErrorContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateCustomEvidenceRequest", - java.util.Optional.of(java.util.List.of()), - securitySource()), - Optional.ofNullable(response), - Optional.ofNullable(error)); - } - - private HttpResponse onSuccess(HttpResponse response) throws Exception { - return sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - this.sdkConfiguration, - this.baseUrl, - "CreateCustomEvidenceRequest", - java.util.Optional.of(java.util.List.of()), - securitySource()), - response); - } - - @Override - public HttpResponse doRequest(CreateCustomEvidenceRequestRequest request) throws Exception { - HttpRequest r = buildRequest(request); - HttpResponse httpRes; - try { - httpRes = client.send(r); - if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { - httpRes = onError(httpRes, null); - } else { - httpRes = onSuccess(httpRes); - } - } catch (Exception e) { - httpRes = onError(null, e); - } - - return httpRes; - } - - - @Override - public CreateCustomEvidenceRequestResponse handleResponse(HttpResponse response) throws Exception { - String contentType = response - .headers() - .firstValue("Content-Type") - .orElse("application/octet-stream"); - CreateCustomEvidenceRequestResponse.Builder resBuilder = - CreateCustomEvidenceRequestResponse - .builder() - .contentType(contentType) - .statusCode(response.statusCode()) - .rawResponse(response); - - CreateCustomEvidenceRequestResponse res = resBuilder.build(); - - if (Utils.statusCodeMatches(response.statusCode(), "200")) { - if (Utils.contentTypeMatches(contentType, "application/json")) { - CustomEvidenceRequest out = Utils.mapper().readValue( - response.body(), - new TypeReference<>() { - }); - res.withCustomEvidenceRequest(out); - return res; - } else { - throw new APIException( - response, - response.statusCode(), - "Unexpected content-type received: " + contentType, - Utils.extractByteArrayFromBody(response)); - } - } - if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - throw new APIException( - response, - response.statusCode(), - "Unexpected status code received: " + response.statusCode(), - Utils.extractByteArrayFromBody(response)); - } -} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditComments.java b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditComments.java new file mode 100644 index 0000000..7c59c5b --- /dev/null +++ b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditComments.java @@ -0,0 +1,194 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.vanta.vanta_auditor_api.operations; + +import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.vanta.vanta_auditor_api.SDKConfiguration; +import com.vanta.vanta_auditor_api.SecuritySource; +import com.vanta.vanta_auditor_api.models.components.PaginatedResponseComment; +import com.vanta.vanta_auditor_api.models.errors.APIException; +import com.vanta.vanta_auditor_api.models.operations.ListAuditCommentsRequest; +import com.vanta.vanta_auditor_api.models.operations.ListAuditCommentsResponse; +import com.vanta.vanta_auditor_api.utils.HTTPClient; +import com.vanta.vanta_auditor_api.utils.HTTPRequest; +import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; +import com.vanta.vanta_auditor_api.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; + + + +public class ListAuditComments { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final HTTPClient client; + + public Base(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + this.client = this.sdkConfiguration.client(); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditComments", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditComments", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditComments", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + HttpRequest buildRequest(ListAuditCommentsRequest request) throws Exception { + String url = Utils.generateURL( + ListAuditCommentsRequest.class, + this.baseUrl, + "/audits/{auditId}/comments", + request, null); + HTTPRequest req = new HTTPRequest(url, "GET"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + + req.addQueryParams(Utils.getQueryParams( + ListAuditCommentsRequest.class, + request, + null)); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync(SDKConfiguration sdkConfiguration) { + super(sdkConfiguration); + } + + private HttpRequest onBuildRequest(ListAuditCommentsRequest request) throws Exception { + HttpRequest req = buildRequest(request); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(ListAuditCommentsRequest request) throws Exception { + HttpRequest r = onBuildRequest(request); + HttpResponse httpRes; + try { + httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + httpRes = onError(httpRes, null); + } else { + httpRes = onSuccess(httpRes); + } + } catch (Exception e) { + httpRes = onError(null, e); + } + + return httpRes; + } + + + @Override + public ListAuditCommentsResponse handleResponse(HttpResponse response) throws Exception { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + ListAuditCommentsResponse.Builder resBuilder = + ListAuditCommentsResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + ListAuditCommentsResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + PaginatedResponseComment out = Utils.mapper().readValue( + response.body(), + new TypeReference<>() { + }); + res.withPaginatedResponseComment(out); + return res; + } else { + throw new APIException( + response, + response.statusCode(), + "Unexpected content-type received: " + contentType, + Utils.extractByteArrayFromBody(response)); + } + } + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + throw new APIException( + response, + response.statusCode(), + "Unexpected status code received: " + response.statusCode(), + Utils.extractByteArrayFromBody(response)); + } + } +} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditCommentsOperation.java b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditCommentsOperation.java deleted file mode 100644 index 93a4ffd..0000000 --- a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditCommentsOperation.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -package com.vanta.vanta_auditor_api.operations; - -import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.SecuritySource; -import com.vanta.vanta_auditor_api.models.components.PaginatedResponseComment; -import com.vanta.vanta_auditor_api.models.errors.APIException; -import com.vanta.vanta_auditor_api.models.operations.ListAuditCommentsRequest; -import com.vanta.vanta_auditor_api.models.operations.ListAuditCommentsResponse; -import com.vanta.vanta_auditor_api.utils.HTTPClient; -import com.vanta.vanta_auditor_api.utils.HTTPRequest; -import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; -import com.vanta.vanta_auditor_api.utils.Utils; -import java.io.InputStream; -import java.lang.Exception; -import java.lang.String; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.Optional; - - -public class ListAuditCommentsOperation implements RequestOperation { - - private final SDKConfiguration sdkConfiguration; - private final String baseUrl; - private final SecuritySource securitySource; - private final HTTPClient client; - - public ListAuditCommentsOperation(SDKConfiguration sdkConfiguration) { - this.sdkConfiguration = sdkConfiguration; - this.baseUrl = this.sdkConfiguration.serverUrl(); - this.securitySource = this.sdkConfiguration.securitySource(); - this.client = this.sdkConfiguration.client(); - } - - private Optional securitySource() { - return Optional.ofNullable(this.securitySource); - } - - public HttpRequest buildRequest(ListAuditCommentsRequest request) throws Exception { - String url = Utils.generateURL( - ListAuditCommentsRequest.class, - this.baseUrl, - "/audits/{auditId}/comments", - request, null); - HTTPRequest req = new HTTPRequest(url, "GET"); - req.addHeader("Accept", "application/json") - .addHeader("user-agent", SDKConfiguration.USER_AGENT); - - req.addQueryParams(Utils.getQueryParams( - ListAuditCommentsRequest.class, - request, - null)); - Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); - - return sdkConfiguration.hooks().beforeRequest( - new BeforeRequestContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditComments", - java.util.Optional.of(java.util.List.of()), - securitySource()), - req.build()); - } - - private HttpResponse onError(HttpResponse response, - Exception error) throws Exception { - return sdkConfiguration.hooks() - .afterError( - new AfterErrorContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditComments", - java.util.Optional.of(java.util.List.of()), - securitySource()), - Optional.ofNullable(response), - Optional.ofNullable(error)); - } - - private HttpResponse onSuccess(HttpResponse response) throws Exception { - return sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditComments", - java.util.Optional.of(java.util.List.of()), - securitySource()), - response); - } - - @Override - public HttpResponse doRequest(ListAuditCommentsRequest request) throws Exception { - HttpRequest r = buildRequest(request); - HttpResponse httpRes; - try { - httpRes = client.send(r); - if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { - httpRes = onError(httpRes, null); - } else { - httpRes = onSuccess(httpRes); - } - } catch (Exception e) { - httpRes = onError(null, e); - } - - return httpRes; - } - - - @Override - public ListAuditCommentsResponse handleResponse(HttpResponse response) throws Exception { - String contentType = response - .headers() - .firstValue("Content-Type") - .orElse("application/octet-stream"); - ListAuditCommentsResponse.Builder resBuilder = - ListAuditCommentsResponse - .builder() - .contentType(contentType) - .statusCode(response.statusCode()) - .rawResponse(response); - - ListAuditCommentsResponse res = resBuilder.build(); - - if (Utils.statusCodeMatches(response.statusCode(), "200")) { - if (Utils.contentTypeMatches(contentType, "application/json")) { - PaginatedResponseComment out = Utils.mapper().readValue( - response.body(), - new TypeReference<>() { - }); - res.withPaginatedResponseComment(out); - return res; - } else { - throw new APIException( - response, - response.statusCode(), - "Unexpected content-type received: " + contentType, - Utils.extractByteArrayFromBody(response)); - } - } - if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - throw new APIException( - response, - response.statusCode(), - "Unexpected status code received: " + response.statusCode(), - Utils.extractByteArrayFromBody(response)); - } -} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditControls.java b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditControls.java new file mode 100644 index 0000000..25b2b33 --- /dev/null +++ b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditControls.java @@ -0,0 +1,194 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.vanta.vanta_auditor_api.operations; + +import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.vanta.vanta_auditor_api.SDKConfiguration; +import com.vanta.vanta_auditor_api.SecuritySource; +import com.vanta.vanta_auditor_api.models.components.PaginatedResponseAuditorControl; +import com.vanta.vanta_auditor_api.models.errors.APIException; +import com.vanta.vanta_auditor_api.models.operations.ListAuditControlsRequest; +import com.vanta.vanta_auditor_api.models.operations.ListAuditControlsResponse; +import com.vanta.vanta_auditor_api.utils.HTTPClient; +import com.vanta.vanta_auditor_api.utils.HTTPRequest; +import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; +import com.vanta.vanta_auditor_api.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; + + + +public class ListAuditControls { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final HTTPClient client; + + public Base(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + this.client = this.sdkConfiguration.client(); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditControls", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditControls", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditControls", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + HttpRequest buildRequest(ListAuditControlsRequest request) throws Exception { + String url = Utils.generateURL( + ListAuditControlsRequest.class, + this.baseUrl, + "/audits/{auditId}/controls", + request, null); + HTTPRequest req = new HTTPRequest(url, "GET"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + + req.addQueryParams(Utils.getQueryParams( + ListAuditControlsRequest.class, + request, + null)); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync(SDKConfiguration sdkConfiguration) { + super(sdkConfiguration); + } + + private HttpRequest onBuildRequest(ListAuditControlsRequest request) throws Exception { + HttpRequest req = buildRequest(request); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(ListAuditControlsRequest request) throws Exception { + HttpRequest r = onBuildRequest(request); + HttpResponse httpRes; + try { + httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + httpRes = onError(httpRes, null); + } else { + httpRes = onSuccess(httpRes); + } + } catch (Exception e) { + httpRes = onError(null, e); + } + + return httpRes; + } + + + @Override + public ListAuditControlsResponse handleResponse(HttpResponse response) throws Exception { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + ListAuditControlsResponse.Builder resBuilder = + ListAuditControlsResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + ListAuditControlsResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + PaginatedResponseAuditorControl out = Utils.mapper().readValue( + response.body(), + new TypeReference<>() { + }); + res.withPaginatedResponseAuditorControl(out); + return res; + } else { + throw new APIException( + response, + response.statusCode(), + "Unexpected content-type received: " + contentType, + Utils.extractByteArrayFromBody(response)); + } + } + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + throw new APIException( + response, + response.statusCode(), + "Unexpected status code received: " + response.statusCode(), + Utils.extractByteArrayFromBody(response)); + } + } +} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditControlsOperation.java b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditControlsOperation.java deleted file mode 100644 index db91186..0000000 --- a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditControlsOperation.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -package com.vanta.vanta_auditor_api.operations; - -import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.SecuritySource; -import com.vanta.vanta_auditor_api.models.components.PaginatedResponseAuditorControl; -import com.vanta.vanta_auditor_api.models.errors.APIException; -import com.vanta.vanta_auditor_api.models.operations.ListAuditControlsRequest; -import com.vanta.vanta_auditor_api.models.operations.ListAuditControlsResponse; -import com.vanta.vanta_auditor_api.utils.HTTPClient; -import com.vanta.vanta_auditor_api.utils.HTTPRequest; -import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; -import com.vanta.vanta_auditor_api.utils.Utils; -import java.io.InputStream; -import java.lang.Exception; -import java.lang.String; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.Optional; - - -public class ListAuditControlsOperation implements RequestOperation { - - private final SDKConfiguration sdkConfiguration; - private final String baseUrl; - private final SecuritySource securitySource; - private final HTTPClient client; - - public ListAuditControlsOperation(SDKConfiguration sdkConfiguration) { - this.sdkConfiguration = sdkConfiguration; - this.baseUrl = this.sdkConfiguration.serverUrl(); - this.securitySource = this.sdkConfiguration.securitySource(); - this.client = this.sdkConfiguration.client(); - } - - private Optional securitySource() { - return Optional.ofNullable(this.securitySource); - } - - public HttpRequest buildRequest(ListAuditControlsRequest request) throws Exception { - String url = Utils.generateURL( - ListAuditControlsRequest.class, - this.baseUrl, - "/audits/{auditId}/controls", - request, null); - HTTPRequest req = new HTTPRequest(url, "GET"); - req.addHeader("Accept", "application/json") - .addHeader("user-agent", SDKConfiguration.USER_AGENT); - - req.addQueryParams(Utils.getQueryParams( - ListAuditControlsRequest.class, - request, - null)); - Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); - - return sdkConfiguration.hooks().beforeRequest( - new BeforeRequestContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditControls", - java.util.Optional.of(java.util.List.of()), - securitySource()), - req.build()); - } - - private HttpResponse onError(HttpResponse response, - Exception error) throws Exception { - return sdkConfiguration.hooks() - .afterError( - new AfterErrorContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditControls", - java.util.Optional.of(java.util.List.of()), - securitySource()), - Optional.ofNullable(response), - Optional.ofNullable(error)); - } - - private HttpResponse onSuccess(HttpResponse response) throws Exception { - return sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditControls", - java.util.Optional.of(java.util.List.of()), - securitySource()), - response); - } - - @Override - public HttpResponse doRequest(ListAuditControlsRequest request) throws Exception { - HttpRequest r = buildRequest(request); - HttpResponse httpRes; - try { - httpRes = client.send(r); - if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { - httpRes = onError(httpRes, null); - } else { - httpRes = onSuccess(httpRes); - } - } catch (Exception e) { - httpRes = onError(null, e); - } - - return httpRes; - } - - - @Override - public ListAuditControlsResponse handleResponse(HttpResponse response) throws Exception { - String contentType = response - .headers() - .firstValue("Content-Type") - .orElse("application/octet-stream"); - ListAuditControlsResponse.Builder resBuilder = - ListAuditControlsResponse - .builder() - .contentType(contentType) - .statusCode(response.statusCode()) - .rawResponse(response); - - ListAuditControlsResponse res = resBuilder.build(); - - if (Utils.statusCodeMatches(response.statusCode(), "200")) { - if (Utils.contentTypeMatches(contentType, "application/json")) { - PaginatedResponseAuditorControl out = Utils.mapper().readValue( - response.body(), - new TypeReference<>() { - }); - res.withPaginatedResponseAuditorControl(out); - return res; - } else { - throw new APIException( - response, - response.statusCode(), - "Unexpected content-type received: " + contentType, - Utils.extractByteArrayFromBody(response)); - } - } - if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - throw new APIException( - response, - response.statusCode(), - "Unexpected status code received: " + response.statusCode(), - Utils.extractByteArrayFromBody(response)); - } -} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidence.java b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidence.java new file mode 100644 index 0000000..909dff4 --- /dev/null +++ b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidence.java @@ -0,0 +1,194 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.vanta.vanta_auditor_api.operations; + +import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.vanta.vanta_auditor_api.SDKConfiguration; +import com.vanta.vanta_auditor_api.SecuritySource; +import com.vanta.vanta_auditor_api.models.components.PaginatedResponseEvidence; +import com.vanta.vanta_auditor_api.models.errors.APIException; +import com.vanta.vanta_auditor_api.models.operations.ListAuditEvidenceRequest; +import com.vanta.vanta_auditor_api.models.operations.ListAuditEvidenceResponse; +import com.vanta.vanta_auditor_api.utils.HTTPClient; +import com.vanta.vanta_auditor_api.utils.HTTPRequest; +import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; +import com.vanta.vanta_auditor_api.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; + + + +public class ListAuditEvidence { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final HTTPClient client; + + public Base(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + this.client = this.sdkConfiguration.client(); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditEvidence", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditEvidence", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditEvidence", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + HttpRequest buildRequest(ListAuditEvidenceRequest request) throws Exception { + String url = Utils.generateURL( + ListAuditEvidenceRequest.class, + this.baseUrl, + "/audits/{auditId}/evidence", + request, null); + HTTPRequest req = new HTTPRequest(url, "GET"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + + req.addQueryParams(Utils.getQueryParams( + ListAuditEvidenceRequest.class, + request, + null)); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync(SDKConfiguration sdkConfiguration) { + super(sdkConfiguration); + } + + private HttpRequest onBuildRequest(ListAuditEvidenceRequest request) throws Exception { + HttpRequest req = buildRequest(request); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(ListAuditEvidenceRequest request) throws Exception { + HttpRequest r = onBuildRequest(request); + HttpResponse httpRes; + try { + httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + httpRes = onError(httpRes, null); + } else { + httpRes = onSuccess(httpRes); + } + } catch (Exception e) { + httpRes = onError(null, e); + } + + return httpRes; + } + + + @Override + public ListAuditEvidenceResponse handleResponse(HttpResponse response) throws Exception { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + ListAuditEvidenceResponse.Builder resBuilder = + ListAuditEvidenceResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + ListAuditEvidenceResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + PaginatedResponseEvidence out = Utils.mapper().readValue( + response.body(), + new TypeReference<>() { + }); + res.withPaginatedResponseEvidence(out); + return res; + } else { + throw new APIException( + response, + response.statusCode(), + "Unexpected content-type received: " + contentType, + Utils.extractByteArrayFromBody(response)); + } + } + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + throw new APIException( + response, + response.statusCode(), + "Unexpected status code received: " + response.statusCode(), + Utils.extractByteArrayFromBody(response)); + } + } +} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceOperation.java b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceOperation.java deleted file mode 100644 index a815a96..0000000 --- a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceOperation.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -package com.vanta.vanta_auditor_api.operations; - -import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.SecuritySource; -import com.vanta.vanta_auditor_api.models.components.PaginatedResponseEvidence; -import com.vanta.vanta_auditor_api.models.errors.APIException; -import com.vanta.vanta_auditor_api.models.operations.ListAuditEvidenceRequest; -import com.vanta.vanta_auditor_api.models.operations.ListAuditEvidenceResponse; -import com.vanta.vanta_auditor_api.utils.HTTPClient; -import com.vanta.vanta_auditor_api.utils.HTTPRequest; -import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; -import com.vanta.vanta_auditor_api.utils.Utils; -import java.io.InputStream; -import java.lang.Exception; -import java.lang.String; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.Optional; - - -public class ListAuditEvidenceOperation implements RequestOperation { - - private final SDKConfiguration sdkConfiguration; - private final String baseUrl; - private final SecuritySource securitySource; - private final HTTPClient client; - - public ListAuditEvidenceOperation(SDKConfiguration sdkConfiguration) { - this.sdkConfiguration = sdkConfiguration; - this.baseUrl = this.sdkConfiguration.serverUrl(); - this.securitySource = this.sdkConfiguration.securitySource(); - this.client = this.sdkConfiguration.client(); - } - - private Optional securitySource() { - return Optional.ofNullable(this.securitySource); - } - - public HttpRequest buildRequest(ListAuditEvidenceRequest request) throws Exception { - String url = Utils.generateURL( - ListAuditEvidenceRequest.class, - this.baseUrl, - "/audits/{auditId}/evidence", - request, null); - HTTPRequest req = new HTTPRequest(url, "GET"); - req.addHeader("Accept", "application/json") - .addHeader("user-agent", SDKConfiguration.USER_AGENT); - - req.addQueryParams(Utils.getQueryParams( - ListAuditEvidenceRequest.class, - request, - null)); - Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); - - return sdkConfiguration.hooks().beforeRequest( - new BeforeRequestContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditEvidence", - java.util.Optional.of(java.util.List.of()), - securitySource()), - req.build()); - } - - private HttpResponse onError(HttpResponse response, - Exception error) throws Exception { - return sdkConfiguration.hooks() - .afterError( - new AfterErrorContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditEvidence", - java.util.Optional.of(java.util.List.of()), - securitySource()), - Optional.ofNullable(response), - Optional.ofNullable(error)); - } - - private HttpResponse onSuccess(HttpResponse response) throws Exception { - return sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditEvidence", - java.util.Optional.of(java.util.List.of()), - securitySource()), - response); - } - - @Override - public HttpResponse doRequest(ListAuditEvidenceRequest request) throws Exception { - HttpRequest r = buildRequest(request); - HttpResponse httpRes; - try { - httpRes = client.send(r); - if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { - httpRes = onError(httpRes, null); - } else { - httpRes = onSuccess(httpRes); - } - } catch (Exception e) { - httpRes = onError(null, e); - } - - return httpRes; - } - - - @Override - public ListAuditEvidenceResponse handleResponse(HttpResponse response) throws Exception { - String contentType = response - .headers() - .firstValue("Content-Type") - .orElse("application/octet-stream"); - ListAuditEvidenceResponse.Builder resBuilder = - ListAuditEvidenceResponse - .builder() - .contentType(contentType) - .statusCode(response.statusCode()) - .rawResponse(response); - - ListAuditEvidenceResponse res = resBuilder.build(); - - if (Utils.statusCodeMatches(response.statusCode(), "200")) { - if (Utils.contentTypeMatches(contentType, "application/json")) { - PaginatedResponseEvidence out = Utils.mapper().readValue( - response.body(), - new TypeReference<>() { - }); - res.withPaginatedResponseEvidence(out); - return res; - } else { - throw new APIException( - response, - response.statusCode(), - "Unexpected content-type received: " + contentType, - Utils.extractByteArrayFromBody(response)); - } - } - if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - throw new APIException( - response, - response.statusCode(), - "Unexpected status code received: " + response.statusCode(), - Utils.extractByteArrayFromBody(response)); - } -} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceUrls.java b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceUrls.java new file mode 100644 index 0000000..620bf2a --- /dev/null +++ b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceUrls.java @@ -0,0 +1,194 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.vanta.vanta_auditor_api.operations; + +import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.vanta.vanta_auditor_api.SDKConfiguration; +import com.vanta.vanta_auditor_api.SecuritySource; +import com.vanta.vanta_auditor_api.models.components.PaginatedResponseEvidenceUrl; +import com.vanta.vanta_auditor_api.models.errors.APIException; +import com.vanta.vanta_auditor_api.models.operations.ListAuditEvidenceUrlsRequest; +import com.vanta.vanta_auditor_api.models.operations.ListAuditEvidenceUrlsResponse; +import com.vanta.vanta_auditor_api.utils.HTTPClient; +import com.vanta.vanta_auditor_api.utils.HTTPRequest; +import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; +import com.vanta.vanta_auditor_api.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; + + + +public class ListAuditEvidenceUrls { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final HTTPClient client; + + public Base(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + this.client = this.sdkConfiguration.client(); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditEvidenceUrls", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditEvidenceUrls", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAuditEvidenceUrls", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + HttpRequest buildRequest(ListAuditEvidenceUrlsRequest request) throws Exception { + String url = Utils.generateURL( + ListAuditEvidenceUrlsRequest.class, + this.baseUrl, + "/audits/{auditId}/evidence/{auditEvidenceId}/urls", + request, null); + HTTPRequest req = new HTTPRequest(url, "GET"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + + req.addQueryParams(Utils.getQueryParams( + ListAuditEvidenceUrlsRequest.class, + request, + null)); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync(SDKConfiguration sdkConfiguration) { + super(sdkConfiguration); + } + + private HttpRequest onBuildRequest(ListAuditEvidenceUrlsRequest request) throws Exception { + HttpRequest req = buildRequest(request); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(ListAuditEvidenceUrlsRequest request) throws Exception { + HttpRequest r = onBuildRequest(request); + HttpResponse httpRes; + try { + httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + httpRes = onError(httpRes, null); + } else { + httpRes = onSuccess(httpRes); + } + } catch (Exception e) { + httpRes = onError(null, e); + } + + return httpRes; + } + + + @Override + public ListAuditEvidenceUrlsResponse handleResponse(HttpResponse response) throws Exception { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + ListAuditEvidenceUrlsResponse.Builder resBuilder = + ListAuditEvidenceUrlsResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + ListAuditEvidenceUrlsResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + PaginatedResponseEvidenceUrl out = Utils.mapper().readValue( + response.body(), + new TypeReference<>() { + }); + res.withPaginatedResponseEvidenceUrl(out); + return res; + } else { + throw new APIException( + response, + response.statusCode(), + "Unexpected content-type received: " + contentType, + Utils.extractByteArrayFromBody(response)); + } + } + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + throw new APIException( + response, + response.statusCode(), + "Unexpected status code received: " + response.statusCode(), + Utils.extractByteArrayFromBody(response)); + } + } +} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceUrlsOperation.java b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceUrlsOperation.java deleted file mode 100644 index d7592a3..0000000 --- a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditEvidenceUrlsOperation.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -package com.vanta.vanta_auditor_api.operations; - -import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.SecuritySource; -import com.vanta.vanta_auditor_api.models.components.PaginatedResponseEvidenceUrl; -import com.vanta.vanta_auditor_api.models.errors.APIException; -import com.vanta.vanta_auditor_api.models.operations.ListAuditEvidenceUrlsRequest; -import com.vanta.vanta_auditor_api.models.operations.ListAuditEvidenceUrlsResponse; -import com.vanta.vanta_auditor_api.utils.HTTPClient; -import com.vanta.vanta_auditor_api.utils.HTTPRequest; -import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; -import com.vanta.vanta_auditor_api.utils.Utils; -import java.io.InputStream; -import java.lang.Exception; -import java.lang.String; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.Optional; - - -public class ListAuditEvidenceUrlsOperation implements RequestOperation { - - private final SDKConfiguration sdkConfiguration; - private final String baseUrl; - private final SecuritySource securitySource; - private final HTTPClient client; - - public ListAuditEvidenceUrlsOperation(SDKConfiguration sdkConfiguration) { - this.sdkConfiguration = sdkConfiguration; - this.baseUrl = this.sdkConfiguration.serverUrl(); - this.securitySource = this.sdkConfiguration.securitySource(); - this.client = this.sdkConfiguration.client(); - } - - private Optional securitySource() { - return Optional.ofNullable(this.securitySource); - } - - public HttpRequest buildRequest(ListAuditEvidenceUrlsRequest request) throws Exception { - String url = Utils.generateURL( - ListAuditEvidenceUrlsRequest.class, - this.baseUrl, - "/audits/{auditId}/evidence/{auditEvidenceId}/urls", - request, null); - HTTPRequest req = new HTTPRequest(url, "GET"); - req.addHeader("Accept", "application/json") - .addHeader("user-agent", SDKConfiguration.USER_AGENT); - - req.addQueryParams(Utils.getQueryParams( - ListAuditEvidenceUrlsRequest.class, - request, - null)); - Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); - - return sdkConfiguration.hooks().beforeRequest( - new BeforeRequestContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditEvidenceUrls", - java.util.Optional.of(java.util.List.of()), - securitySource()), - req.build()); - } - - private HttpResponse onError(HttpResponse response, - Exception error) throws Exception { - return sdkConfiguration.hooks() - .afterError( - new AfterErrorContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditEvidenceUrls", - java.util.Optional.of(java.util.List.of()), - securitySource()), - Optional.ofNullable(response), - Optional.ofNullable(error)); - } - - private HttpResponse onSuccess(HttpResponse response) throws Exception { - return sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAuditEvidenceUrls", - java.util.Optional.of(java.util.List.of()), - securitySource()), - response); - } - - @Override - public HttpResponse doRequest(ListAuditEvidenceUrlsRequest request) throws Exception { - HttpRequest r = buildRequest(request); - HttpResponse httpRes; - try { - httpRes = client.send(r); - if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { - httpRes = onError(httpRes, null); - } else { - httpRes = onSuccess(httpRes); - } - } catch (Exception e) { - httpRes = onError(null, e); - } - - return httpRes; - } - - - @Override - public ListAuditEvidenceUrlsResponse handleResponse(HttpResponse response) throws Exception { - String contentType = response - .headers() - .firstValue("Content-Type") - .orElse("application/octet-stream"); - ListAuditEvidenceUrlsResponse.Builder resBuilder = - ListAuditEvidenceUrlsResponse - .builder() - .contentType(contentType) - .statusCode(response.statusCode()) - .rawResponse(response); - - ListAuditEvidenceUrlsResponse res = resBuilder.build(); - - if (Utils.statusCodeMatches(response.statusCode(), "200")) { - if (Utils.contentTypeMatches(contentType, "application/json")) { - PaginatedResponseEvidenceUrl out = Utils.mapper().readValue( - response.body(), - new TypeReference<>() { - }); - res.withPaginatedResponseEvidenceUrl(out); - return res; - } else { - throw new APIException( - response, - response.statusCode(), - "Unexpected content-type received: " + contentType, - Utils.extractByteArrayFromBody(response)); - } - } - if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - throw new APIException( - response, - response.statusCode(), - "Unexpected status code received: " + response.statusCode(), - Utils.extractByteArrayFromBody(response)); - } -} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAudits.java b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAudits.java new file mode 100644 index 0000000..d4ecae1 --- /dev/null +++ b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAudits.java @@ -0,0 +1,192 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.vanta.vanta_auditor_api.operations; + +import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.vanta.vanta_auditor_api.SDKConfiguration; +import com.vanta.vanta_auditor_api.SecuritySource; +import com.vanta.vanta_auditor_api.models.components.PaginatedResponseAudit; +import com.vanta.vanta_auditor_api.models.errors.APIException; +import com.vanta.vanta_auditor_api.models.operations.ListAuditsRequest; +import com.vanta.vanta_auditor_api.models.operations.ListAuditsResponse; +import com.vanta.vanta_auditor_api.utils.HTTPClient; +import com.vanta.vanta_auditor_api.utils.HTTPRequest; +import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; +import com.vanta.vanta_auditor_api.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; + + + +public class ListAudits { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final HTTPClient client; + + public Base(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + this.client = this.sdkConfiguration.client(); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAudits", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAudits", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAudits", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + HttpRequest buildRequest(ListAuditsRequest request) throws Exception { + String url = Utils.generateURL( + this.baseUrl, + "/audits"); + HTTPRequest req = new HTTPRequest(url, "GET"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + + req.addQueryParams(Utils.getQueryParams( + ListAuditsRequest.class, + request, + null)); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync(SDKConfiguration sdkConfiguration) { + super(sdkConfiguration); + } + + private HttpRequest onBuildRequest(ListAuditsRequest request) throws Exception { + HttpRequest req = buildRequest(request); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(ListAuditsRequest request) throws Exception { + HttpRequest r = onBuildRequest(request); + HttpResponse httpRes; + try { + httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + httpRes = onError(httpRes, null); + } else { + httpRes = onSuccess(httpRes); + } + } catch (Exception e) { + httpRes = onError(null, e); + } + + return httpRes; + } + + + @Override + public ListAuditsResponse handleResponse(HttpResponse response) throws Exception { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + ListAuditsResponse.Builder resBuilder = + ListAuditsResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + ListAuditsResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + PaginatedResponseAudit out = Utils.mapper().readValue( + response.body(), + new TypeReference<>() { + }); + res.withPaginatedResponseAudit(out); + return res; + } else { + throw new APIException( + response, + response.statusCode(), + "Unexpected content-type received: " + contentType, + Utils.extractByteArrayFromBody(response)); + } + } + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + throw new APIException( + response, + response.statusCode(), + "Unexpected status code received: " + response.statusCode(), + Utils.extractByteArrayFromBody(response)); + } + } +} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditsOperation.java b/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditsOperation.java deleted file mode 100644 index 03fe7a4..0000000 --- a/src/main/java/com/vanta/vanta_auditor_api/operations/ListAuditsOperation.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -package com.vanta.vanta_auditor_api.operations; - -import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.SecuritySource; -import com.vanta.vanta_auditor_api.models.components.PaginatedResponseAudit; -import com.vanta.vanta_auditor_api.models.errors.APIException; -import com.vanta.vanta_auditor_api.models.operations.ListAuditsRequest; -import com.vanta.vanta_auditor_api.models.operations.ListAuditsResponse; -import com.vanta.vanta_auditor_api.utils.HTTPClient; -import com.vanta.vanta_auditor_api.utils.HTTPRequest; -import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; -import com.vanta.vanta_auditor_api.utils.Utils; -import java.io.InputStream; -import java.lang.Exception; -import java.lang.String; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.Optional; - - -public class ListAuditsOperation implements RequestOperation { - - private final SDKConfiguration sdkConfiguration; - private final String baseUrl; - private final SecuritySource securitySource; - private final HTTPClient client; - - public ListAuditsOperation(SDKConfiguration sdkConfiguration) { - this.sdkConfiguration = sdkConfiguration; - this.baseUrl = this.sdkConfiguration.serverUrl(); - this.securitySource = this.sdkConfiguration.securitySource(); - this.client = this.sdkConfiguration.client(); - } - - private Optional securitySource() { - return Optional.ofNullable(this.securitySource); - } - - public HttpRequest buildRequest(ListAuditsRequest request) throws Exception { - String url = Utils.generateURL( - this.baseUrl, - "/audits"); - HTTPRequest req = new HTTPRequest(url, "GET"); - req.addHeader("Accept", "application/json") - .addHeader("user-agent", SDKConfiguration.USER_AGENT); - - req.addQueryParams(Utils.getQueryParams( - ListAuditsRequest.class, - request, - null)); - Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); - - return sdkConfiguration.hooks().beforeRequest( - new BeforeRequestContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAudits", - java.util.Optional.of(java.util.List.of()), - securitySource()), - req.build()); - } - - private HttpResponse onError(HttpResponse response, - Exception error) throws Exception { - return sdkConfiguration.hooks() - .afterError( - new AfterErrorContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAudits", - java.util.Optional.of(java.util.List.of()), - securitySource()), - Optional.ofNullable(response), - Optional.ofNullable(error)); - } - - private HttpResponse onSuccess(HttpResponse response) throws Exception { - return sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - this.sdkConfiguration, - this.baseUrl, - "ListAudits", - java.util.Optional.of(java.util.List.of()), - securitySource()), - response); - } - - @Override - public HttpResponse doRequest(ListAuditsRequest request) throws Exception { - HttpRequest r = buildRequest(request); - HttpResponse httpRes; - try { - httpRes = client.send(r); - if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { - httpRes = onError(httpRes, null); - } else { - httpRes = onSuccess(httpRes); - } - } catch (Exception e) { - httpRes = onError(null, e); - } - - return httpRes; - } - - - @Override - public ListAuditsResponse handleResponse(HttpResponse response) throws Exception { - String contentType = response - .headers() - .firstValue("Content-Type") - .orElse("application/octet-stream"); - ListAuditsResponse.Builder resBuilder = - ListAuditsResponse - .builder() - .contentType(contentType) - .statusCode(response.statusCode()) - .rawResponse(response); - - ListAuditsResponse res = resBuilder.build(); - - if (Utils.statusCodeMatches(response.statusCode(), "200")) { - if (Utils.contentTypeMatches(contentType, "application/json")) { - PaginatedResponseAudit out = Utils.mapper().readValue( - response.body(), - new TypeReference<>() { - }); - res.withPaginatedResponseAudit(out); - return res; - } else { - throw new APIException( - response, - response.statusCode(), - "Unexpected content-type received: " + contentType, - Utils.extractByteArrayFromBody(response)); - } - } - if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - throw new APIException( - response, - response.statusCode(), - "Unexpected status code received: " + response.statusCode(), - Utils.extractByteArrayFromBody(response)); - } -} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/UpdateAuditEvidence.java b/src/main/java/com/vanta/vanta_auditor_api/operations/UpdateAuditEvidence.java new file mode 100644 index 0000000..bad205a --- /dev/null +++ b/src/main/java/com/vanta/vanta_auditor_api/operations/UpdateAuditEvidence.java @@ -0,0 +1,206 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.vanta.vanta_auditor_api.operations; + +import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.vanta.vanta_auditor_api.SDKConfiguration; +import com.vanta.vanta_auditor_api.SecuritySource; +import com.vanta.vanta_auditor_api.models.components.Evidence; +import com.vanta.vanta_auditor_api.models.errors.APIException; +import com.vanta.vanta_auditor_api.models.operations.UpdateAuditEvidenceRequest; +import com.vanta.vanta_auditor_api.models.operations.UpdateAuditEvidenceResponse; +import com.vanta.vanta_auditor_api.utils.HTTPClient; +import com.vanta.vanta_auditor_api.utils.HTTPRequest; +import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; +import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; +import com.vanta.vanta_auditor_api.utils.SerializedBody; +import com.vanta.vanta_auditor_api.utils.Utils.JsonShape; +import com.vanta.vanta_auditor_api.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.Object; +import java.lang.String; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; + + + +public class UpdateAuditEvidence { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final HTTPClient client; + + public Base(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + this.client = this.sdkConfiguration.client(); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "UpdateAuditEvidence", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "UpdateAuditEvidence", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "UpdateAuditEvidence", + java.util.Optional.of(java.util.List.of()), + securitySource()); + } + + HttpRequest buildRequest(UpdateAuditEvidenceRequest request) throws Exception { + String url = Utils.generateURL( + UpdateAuditEvidenceRequest.class, + this.baseUrl, + "/audits/{auditId}/evidence/{auditEvidenceId}", + request, null); + HTTPRequest req = new HTTPRequest(url, "PATCH"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + new TypeReference() { + }); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "auditEvidenceUpdateInput", + "json", + false); + if (serializedRequestBody == null) { + throw new Exception("Request body is required"); + } + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync(SDKConfiguration sdkConfiguration) { + super(sdkConfiguration); + } + + private HttpRequest onBuildRequest(UpdateAuditEvidenceRequest request) throws Exception { + HttpRequest req = buildRequest(request); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(UpdateAuditEvidenceRequest request) throws Exception { + HttpRequest r = onBuildRequest(request); + HttpResponse httpRes; + try { + httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + httpRes = onError(httpRes, null); + } else { + httpRes = onSuccess(httpRes); + } + } catch (Exception e) { + httpRes = onError(null, e); + } + + return httpRes; + } + + + @Override + public UpdateAuditEvidenceResponse handleResponse(HttpResponse response) throws Exception { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + UpdateAuditEvidenceResponse.Builder resBuilder = + UpdateAuditEvidenceResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + UpdateAuditEvidenceResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + Evidence out = Utils.mapper().readValue( + response.body(), + new TypeReference<>() { + }); + res.withEvidence(out); + return res; + } else { + throw new APIException( + response, + response.statusCode(), + "Unexpected content-type received: " + contentType, + Utils.extractByteArrayFromBody(response)); + } + } + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw new APIException( + response, + response.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(response)); + } + + throw new APIException( + response, + response.statusCode(), + "Unexpected status code received: " + response.statusCode(), + Utils.extractByteArrayFromBody(response)); + } + } +} diff --git a/src/main/java/com/vanta/vanta_auditor_api/operations/UpdateAuditEvidenceOperation.java b/src/main/java/com/vanta/vanta_auditor_api/operations/UpdateAuditEvidenceOperation.java deleted file mode 100644 index a6785f2..0000000 --- a/src/main/java/com/vanta/vanta_auditor_api/operations/UpdateAuditEvidenceOperation.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -package com.vanta.vanta_auditor_api.operations; - -import static com.vanta.vanta_auditor_api.operations.Operations.RequestOperation; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.vanta.vanta_auditor_api.SDKConfiguration; -import com.vanta.vanta_auditor_api.SecuritySource; -import com.vanta.vanta_auditor_api.models.components.Evidence; -import com.vanta.vanta_auditor_api.models.errors.APIException; -import com.vanta.vanta_auditor_api.models.operations.UpdateAuditEvidenceRequest; -import com.vanta.vanta_auditor_api.models.operations.UpdateAuditEvidenceResponse; -import com.vanta.vanta_auditor_api.utils.HTTPClient; -import com.vanta.vanta_auditor_api.utils.HTTPRequest; -import com.vanta.vanta_auditor_api.utils.Hook.AfterErrorContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.AfterSuccessContextImpl; -import com.vanta.vanta_auditor_api.utils.Hook.BeforeRequestContextImpl; -import com.vanta.vanta_auditor_api.utils.SerializedBody; -import com.vanta.vanta_auditor_api.utils.Utils.JsonShape; -import com.vanta.vanta_auditor_api.utils.Utils; -import java.io.InputStream; -import java.lang.Exception; -import java.lang.Object; -import java.lang.String; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.Optional; - - -public class UpdateAuditEvidenceOperation implements RequestOperation { - - private final SDKConfiguration sdkConfiguration; - private final String baseUrl; - private final SecuritySource securitySource; - private final HTTPClient client; - - public UpdateAuditEvidenceOperation(SDKConfiguration sdkConfiguration) { - this.sdkConfiguration = sdkConfiguration; - this.baseUrl = this.sdkConfiguration.serverUrl(); - this.securitySource = this.sdkConfiguration.securitySource(); - this.client = this.sdkConfiguration.client(); - } - - private Optional securitySource() { - return Optional.ofNullable(this.securitySource); - } - - public HttpRequest buildRequest(UpdateAuditEvidenceRequest request) throws Exception { - String url = Utils.generateURL( - UpdateAuditEvidenceRequest.class, - this.baseUrl, - "/audits/{auditId}/evidence/{auditEvidenceId}", - request, null); - HTTPRequest req = new HTTPRequest(url, "PATCH"); - Object convertedRequest = Utils.convertToShape( - request, - JsonShape.DEFAULT, - new TypeReference() {}); - SerializedBody serializedRequestBody = Utils.serializeRequestBody( - convertedRequest, - "auditEvidenceUpdateInput", - "json", - false); - if (serializedRequestBody == null) { - throw new Exception("Request body is required"); - } - req.setBody(Optional.ofNullable(serializedRequestBody)); - req.addHeader("Accept", "application/json") - .addHeader("user-agent", SDKConfiguration.USER_AGENT); - Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); - - return sdkConfiguration.hooks().beforeRequest( - new BeforeRequestContextImpl( - this.sdkConfiguration, - this.baseUrl, - "UpdateAuditEvidence", - java.util.Optional.of(java.util.List.of()), - securitySource()), - req.build()); - } - - private HttpResponse onError(HttpResponse response, - Exception error) throws Exception { - return sdkConfiguration.hooks() - .afterError( - new AfterErrorContextImpl( - this.sdkConfiguration, - this.baseUrl, - "UpdateAuditEvidence", - java.util.Optional.of(java.util.List.of()), - securitySource()), - Optional.ofNullable(response), - Optional.ofNullable(error)); - } - - private HttpResponse onSuccess(HttpResponse response) throws Exception { - return sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - this.sdkConfiguration, - this.baseUrl, - "UpdateAuditEvidence", - java.util.Optional.of(java.util.List.of()), - securitySource()), - response); - } - - @Override - public HttpResponse doRequest(UpdateAuditEvidenceRequest request) throws Exception { - HttpRequest r = buildRequest(request); - HttpResponse httpRes; - try { - httpRes = client.send(r); - if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { - httpRes = onError(httpRes, null); - } else { - httpRes = onSuccess(httpRes); - } - } catch (Exception e) { - httpRes = onError(null, e); - } - - return httpRes; - } - - - @Override - public UpdateAuditEvidenceResponse handleResponse(HttpResponse response) throws Exception { - String contentType = response - .headers() - .firstValue("Content-Type") - .orElse("application/octet-stream"); - UpdateAuditEvidenceResponse.Builder resBuilder = - UpdateAuditEvidenceResponse - .builder() - .contentType(contentType) - .statusCode(response.statusCode()) - .rawResponse(response); - - UpdateAuditEvidenceResponse res = resBuilder.build(); - - if (Utils.statusCodeMatches(response.statusCode(), "200")) { - if (Utils.contentTypeMatches(contentType, "application/json")) { - Evidence out = Utils.mapper().readValue( - response.body(), - new TypeReference<>() { - }); - res.withEvidence(out); - return res; - } else { - throw new APIException( - response, - response.statusCode(), - "Unexpected content-type received: " + contentType, - Utils.extractByteArrayFromBody(response)); - } - } - if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { - // no content - throw new APIException( - response, - response.statusCode(), - "API error occurred", - Utils.extractByteArrayFromBody(response)); - } - throw new APIException( - response, - response.statusCode(), - "Unexpected status code received: " + response.statusCode(), - Utils.extractByteArrayFromBody(response)); - } -} diff --git a/src/main/java/com/vanta/vanta_auditor_api/utils/HTTPClient.java b/src/main/java/com/vanta/vanta_auditor_api/utils/HTTPClient.java index bd1d358..22120d6 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/utils/HTTPClient.java +++ b/src/main/java/com/vanta/vanta_auditor_api/utils/HTTPClient.java @@ -6,29 +6,34 @@ import java.io.IOException; import java.io.InputStream; import java.net.URISyntaxException; -import java.net.http.HttpResponse; +import java.net.http.HttpClient; import java.net.http.HttpRequest; -import java.util.concurrent.CompletableFuture; +import java.net.http.HttpResponse; public interface HTTPClient { + HttpClient client = HttpClient.newHttpClient(); /** * Sends an HTTP request and returns the response. - * - *

Note that {@link HttpRequest} is immutable. To modify the request you can use - * {@code HttpRequest#newBuilder(HttpRequest, BiPredicate)} with - * JDK 16 and later (which will copy the request for modification in a builder). - * If that method is not available then use {@link Helpers#copy} (which also returns - * a builder). - * + * + *

+ * Note that {@link HttpRequest} is immutable. To modify the request you can + * use + * {@code HttpRequest#newBuilder(HttpRequest, BiPredicate)} + * with JDK 16 and later (which will copy the request for modification in a + * builder). If that method is not available then use {@link Helpers#copy} + * (which also returns a builder). + * * @param request HTTP request * @return HTTP response * @throws IOException * @throws InterruptedException * @throws URISyntaxException - */ - HttpResponse send(HttpRequest request) - throws IOException, InterruptedException, URISyntaxException; + */ + default HttpResponse send(HttpRequest request) + throws IOException, InterruptedException, URISyntaxException { + return client.send(request, HttpResponse.BodyHandlers.ofInputStream()); + } /** * Controls the debug flag that can be used by clients to perform conditional diff --git a/src/main/java/com/vanta/vanta_auditor_api/utils/Hooks.java b/src/main/java/com/vanta/vanta_auditor_api/utils/Hooks.java index 609acad..b9d2b36 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/utils/Hooks.java +++ b/src/main/java/com/vanta/vanta_auditor_api/utils/Hooks.java @@ -27,7 +27,7 @@ * For example, this code will add a transaction id header to every request: * *

- * hooks.registerBeforeRequest((context, request) -> {
+ * hooks.registerBeforeRequest((context, request) -> {
  *     request.headers().map().put("acme-transaction-id", nextTransactionId());
  *     return request;
  * });
diff --git a/src/main/java/com/vanta/vanta_auditor_api/utils/ResponseWithBody.java b/src/main/java/com/vanta/vanta_auditor_api/utils/ResponseWithBody.java
new file mode 100644
index 0000000..2dacf5c
--- /dev/null
+++ b/src/main/java/com/vanta/vanta_auditor_api/utils/ResponseWithBody.java
@@ -0,0 +1,82 @@
+/* 
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.vanta.vanta_auditor_api.utils;
+
+import javax.net.ssl.SSLSession;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpHeaders;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.util.Optional;
+import java.util.function.Function;
+
+/**
+ * A wrapper for {@link HttpResponse} that allows mappi ng the response body from type {@code R} to type {@code B}.
+ * 

+ * This class delegates all methods to the original response, except for {@link #body()}, which returns the mapped body. + * The mapping is performed using the provided {@code bodyMapper} function at construction time. + * + * @param the type of the original response body + * @param the type of the mapped response body + */ +public class ResponseWithBody implements HttpResponse { + private final HttpResponse original; + private final Function bodyMapper; + private final B body; + + /** + * Constructs a new {@code ResponseWithBody} by wrapping an existing {@link HttpResponse} and applying + * a mapping function to its body. + * + * @param original the original response to wrap + * @param bodyMapper a function to map the original body to the new body type + */ + public ResponseWithBody(HttpResponse original, Function bodyMapper) { + this.original = original; + this.bodyMapper = bodyMapper; + this.body = bodyMapper.apply(original.body()); + } + + @Override + public int statusCode() { + return original.statusCode(); + } + + @Override + public HttpRequest request() { + return original.request(); + } + + @Override + public Optional> previousResponse() { + return original.previousResponse() + .map(prev -> new ResponseWithBody<>(prev, bodyMapper)); + } + + @Override + public HttpHeaders headers() { + return original.headers(); + } + + @Override + public B body() { + return body; + } + + @Override + public Optional sslSession() { + return original.sslSession(); + } + + @Override + public URI uri() { + return original.uri(); + } + + @Override + public HttpClient.Version version() { + return original.version(); + } +} diff --git a/src/main/java/com/vanta/vanta_auditor_api/utils/Utils.java b/src/main/java/com/vanta/vanta_auditor_api/utils/Utils.java index 8f4a2af..17c08f6 100644 --- a/src/main/java/com/vanta/vanta_auditor_api/utils/Utils.java +++ b/src/main/java/com/vanta/vanta_auditor_api/utils/Utils.java @@ -52,6 +52,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; +import java.util.concurrent.CompletableFuture; import javax.net.ssl.SSLSession;