Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kotlin: Pull in change from latest codegen #1775

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions kotlin/lib/src/main/kotlin/Environment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// this file is @generated
package com.svix.kotlin

import com.svix.kotlin.models.EnvironmentIn
import com.svix.kotlin.models.EnvironmentOut
import okhttp3.Headers

data class EnvironmentExportOptions(val idempotencyKey: String? = null)

data class EnvironmentImportOptions(val idempotencyKey: String? = null)

class Environment(private val client: SvixHttpClient) {

/** Download a JSON file containing all org-settings and event types. */
suspend fun export(
options: EnvironmentExportOptions = EnvironmentExportOptions()
): EnvironmentOut {
val url = client.newUrlBuilder().encodedPath("/api/v1/environment/export")
val headers = Headers.Builder()
options.idempotencyKey?.let { headers.add("idempotency-key", it) }
return client.executeRequest<Any, EnvironmentOut>(
"POST",
url.build(),
headers = headers.build(),
)
}

/**
* Import a configuration into the active organization. It doesn't delete anything, only
* adds/updates what was passed to it.
*/
suspend fun import(
environmentIn: EnvironmentIn,
options: EnvironmentImportOptions = EnvironmentImportOptions(),
) {
val url = client.newUrlBuilder().encodedPath("/api/v1/environment/import")
val headers = Headers.Builder()
options.idempotencyKey?.let { headers.add("idempotency-key", it) }

client.executeRequest<EnvironmentIn, Boolean>(
"POST",
url.build(),
headers = headers.build(),
reqBody = environmentIn,
)
}
}
11 changes: 11 additions & 0 deletions kotlin/lib/src/main/kotlin/Health.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// this file is @generated
package com.svix.kotlin

class Health(private val client: SvixHttpClient) {

/** Verify the API server is up and running. */
suspend fun get() {
val url = client.newUrlBuilder().encodedPath("/api/v1/health")
client.executeRequest<Any, Boolean>("GET", url.build())
}
}
157 changes: 157 additions & 0 deletions kotlin/lib/src/main/kotlin/IngestEndpoint.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
// this file is @generated
package com.svix.kotlin

import com.svix.kotlin.models.IngestEndpointHeadersIn
import com.svix.kotlin.models.IngestEndpointHeadersOut
import com.svix.kotlin.models.IngestEndpointIn
import com.svix.kotlin.models.IngestEndpointOut
import com.svix.kotlin.models.IngestEndpointSecretIn
import com.svix.kotlin.models.IngestEndpointSecretOut
import com.svix.kotlin.models.IngestEndpointUpdate
import com.svix.kotlin.models.ListResponseIngestEndpointOut
import com.svix.kotlin.models.Ordering
import okhttp3.Headers

data class IngestEndpointListOptions(
/** Limit the number of returned items */
val limit: ULong? = null,
/** The iterator returned from a prior invocation */
val iterator: String? = null,
/** The sorting order of the returned items */
val order: Ordering? = null,
)

data class IngestEndpointCreateOptions(val idempotencyKey: String? = null)

data class IngestEndpointRotateSecretOptions(val idempotencyKey: String? = null)

class IngestEndpoint(private val client: SvixHttpClient) {

/** List ingest endpoints. */
suspend fun list(
options: IngestEndpointListOptions = IngestEndpointListOptions()
): ListResponseIngestEndpointOut {
val url = client.newUrlBuilder().encodedPath("/ingest/api/v1/source/{source_id}/endpoint")
options.limit?.let { url.addQueryParameter("limit", serializeQueryParam(it)) }
options.iterator?.let { url.addQueryParameter("iterator", it) }
options.order?.let { url.addQueryParameter("order", serializeQueryParam(it)) }
return client.executeRequest<Any, ListResponseIngestEndpointOut>("GET", url.build())
}

/** Create an ingest endpoint. */
suspend fun create(
ingestEndpointIn: IngestEndpointIn,
options: IngestEndpointCreateOptions = IngestEndpointCreateOptions(),
): IngestEndpointOut {
val url = client.newUrlBuilder().encodedPath("/ingest/api/v1/source/{source_id}/endpoint")
val headers = Headers.Builder()
options.idempotencyKey?.let { headers.add("idempotency-key", it) }

return client.executeRequest<IngestEndpointIn, IngestEndpointOut>(
"POST",
url.build(),
headers = headers.build(),
reqBody = ingestEndpointIn,
)
}

/** Get an ingest endpoint. */
suspend fun get(endpointId: String): IngestEndpointOut {
val url =
client
.newUrlBuilder()
.encodedPath("/ingest/api/v1/source/{source_id}/endpoint/$endpointId")
return client.executeRequest<Any, IngestEndpointOut>("GET", url.build())
}

/** Update an ingest endpoint. */
suspend fun update(
endpointId: String,
ingestEndpointUpdate: IngestEndpointUpdate,
): IngestEndpointOut {
val url =
client
.newUrlBuilder()
.encodedPath("/ingest/api/v1/source/{source_id}/endpoint/$endpointId")

return client.executeRequest<IngestEndpointUpdate, IngestEndpointOut>(
"PUT",
url.build(),
reqBody = ingestEndpointUpdate,
)
}

/** Delete an ingest endpoint. */
suspend fun delete(endpointId: String) {
val url =
client
.newUrlBuilder()
.encodedPath("/ingest/api/v1/source/{source_id}/endpoint/$endpointId")
client.executeRequest<Any, Boolean>("DELETE", url.build())
}

/** Get the additional headers to be sent with the ingest. */
suspend fun getHeaders(endpointId: String): IngestEndpointHeadersOut {
val url =
client
.newUrlBuilder()
.encodedPath("/ingest/api/v1/source/{source_id}/endpoint/$endpointId/headers")
return client.executeRequest<Any, IngestEndpointHeadersOut>("GET", url.build())
}

/** Set the additional headers to be sent to the endpoint. */
suspend fun updateHeaders(
endpointId: String,
ingestEndpointHeadersIn: IngestEndpointHeadersIn,
) {
val url =
client
.newUrlBuilder()
.encodedPath("/ingest/api/v1/source/{source_id}/endpoint/$endpointId/headers")

client.executeRequest<IngestEndpointHeadersIn, Boolean>(
"PUT",
url.build(),
reqBody = ingestEndpointHeadersIn,
)
}

/**
* Get an ingest endpoint's signing secret.
*
* This is used to verify the authenticity of the webhook. For more information please refer to
* [the consuming webhooks docs](https://docs.svix.com/consuming-webhooks/).
*/
suspend fun getSecret(endpointId: String): IngestEndpointSecretOut {
val url =
client
.newUrlBuilder()
.encodedPath("/ingest/api/v1/source/{source_id}/endpoint/$endpointId/secret")
return client.executeRequest<Any, IngestEndpointSecretOut>("GET", url.build())
}

/**
* Rotates an ingest endpoint's signing secret.
*
* The previous secret will remain valid for the next 24 hours.
*/
suspend fun rotateSecret(
endpointId: String,
ingestEndpointSecretIn: IngestEndpointSecretIn,
options: IngestEndpointRotateSecretOptions = IngestEndpointRotateSecretOptions(),
) {
val url =
client
.newUrlBuilder()
.encodedPath("/ingest/api/v1/source/{source_id}/endpoint/$endpointId/secret/rotate")
val headers = Headers.Builder()
options.idempotencyKey?.let { headers.add("idempotency-key", it) }

client.executeRequest<IngestEndpointSecretIn, Boolean>(
"POST",
url.build(),
headers = headers.build(),
reqBody = ingestEndpointSecretIn,
)
}
}
6 changes: 3 additions & 3 deletions kotlin/lib/src/main/kotlin/Message.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package com.svix.kotlin

import com.svix.kotlin.models.ApplicationIn
import com.svix.kotlin.models.ExpungAllContentsOut
import com.svix.kotlin.models.ExpungeAllContentsOut
import com.svix.kotlin.models.ListResponseMessageOut
import com.svix.kotlin.models.MessageIn
import com.svix.kotlin.models.MessageOut
Expand Down Expand Up @@ -117,11 +117,11 @@ class Message(private val client: SvixHttpClient) {
suspend fun expungeAllContents(
appId: String,
options: MessageExpungeAllContentsOptions = MessageExpungeAllContentsOptions(),
): ExpungAllContentsOut {
): ExpungeAllContentsOut {
val url = client.newUrlBuilder().encodedPath("/api/v1/app/$appId/msg/expunge-all-contents")
val headers = Headers.Builder()
options.idempotencyKey?.let { headers.add("idempotency-key", it) }
return client.executeRequest<Any, ExpungAllContentsOut>(
return client.executeRequest<Any, ExpungeAllContentsOut>(
"POST",
url.build(),
headers = headers.build(),
Expand Down
1 change: 1 addition & 0 deletions kotlin/lib/src/main/kotlin/models/EndpointIn.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ data class EndpointIn(
val description: String? = null,
val disabled: Boolean? = null,
val filterTypes: Set<String>? = null,
val headers: Map<String, String>? = null,
val metadata: Map<String, String>? = null,
val rateLimit: UShort? = null,
val secret: String? = null,
Expand Down
11 changes: 11 additions & 0 deletions kotlin/lib/src/main/kotlin/models/ExpungeAllContentsOut.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file is @generated
package com.svix.kotlin.models

import kotlinx.serialization.Serializable

@Serializable
data class ExpungeAllContentsOut(
val id: String,
val status: BackgroundTaskStatus,
val task: BackgroundTaskType,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is @generated
package com.svix.kotlin.models

import kotlinx.serialization.Serializable

@Serializable data class IngestEndpointHeadersIn(val headers: Map<String, String>)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file is @generated
package com.svix.kotlin.models

import kotlinx.serialization.Serializable

@Serializable
data class IngestEndpointHeadersOut(val headers: Map<String, String>, val sensitive: Set<String>)
15 changes: 15 additions & 0 deletions kotlin/lib/src/main/kotlin/models/IngestEndpointIn.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This file is @generated
package com.svix.kotlin.models

import kotlinx.serialization.Serializable

@Serializable
data class IngestEndpointIn(
val description: String? = null,
val disabled: Boolean? = null,
val metadata: Map<String, String>? = null,
val rateLimit: UShort? = null,
val secret: String? = null,
val uid: String? = null,
val url: String,
)
18 changes: 18 additions & 0 deletions kotlin/lib/src/main/kotlin/models/IngestEndpointOut.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This file is @generated
package com.svix.kotlin.models

import kotlinx.datetime.Instant
import kotlinx.serialization.Serializable

@Serializable
data class IngestEndpointOut(
val createdAt: Instant,
val description: String,
val disabled: Boolean? = null,
val id: String,
val metadata: Map<String, String>,
val rateLimit: UShort? = null,
val uid: String? = null,
val updatedAt: Instant,
val url: String,
)
6 changes: 6 additions & 0 deletions kotlin/lib/src/main/kotlin/models/IngestEndpointSecretIn.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is @generated
package com.svix.kotlin.models

import kotlinx.serialization.Serializable

@Serializable data class IngestEndpointSecretIn(val key: String? = null)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is @generated
package com.svix.kotlin.models

import kotlinx.serialization.Serializable

@Serializable data class IngestEndpointSecretOut(val key: String)
14 changes: 14 additions & 0 deletions kotlin/lib/src/main/kotlin/models/IngestEndpointUpdate.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This file is @generated
package com.svix.kotlin.models

import kotlinx.serialization.Serializable

@Serializable
data class IngestEndpointUpdate(
val description: String? = null,
val disabled: Boolean? = null,
val metadata: Map<String, String>? = null,
val rateLimit: UShort? = null,
val uid: String? = null,
val url: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This file is @generated
package com.svix.kotlin.models

import kotlinx.serialization.Serializable

@Serializable
data class ListResponseIngestEndpointOut(
val data: List<IngestEndpointOut>,
val done: Boolean,
val iterator: String? = null,
val prevIterator: String? = null,
)
16 changes: 16 additions & 0 deletions kotlin/templates/api_extra/application_create.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** Get or create an application. */
suspend fun getOrCreate(
applicationIn: ApplicationIn,
options: ApplicationCreateOptions = ApplicationCreateOptions()
): ApplicationOut {
val url = client.newUrlBuilder().encodedPath("/api/v1/app").addQueryParameter("get_if_exists","true")
var headers = Headers.Builder()
options.idempotencyKey?.let { headers = headers.add("idempotency-key", it) }

return client.executeRequest<ApplicationIn, ApplicationOut>(
"POST",
url.build(),
headers = headers.build(),
reqBody = applicationIn,
)
}
Loading