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: Update codegen templates to support struct enums #1793

Merged
merged 4 commits into from
Mar 6, 2025
Merged
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
24 changes: 12 additions & 12 deletions codegen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ output_dir = "rust/src/models"
#output_dir = "go/models"
#
#
#[kotlin]
#extra_shell_commands = [
# "rm kotlin/lib/src/main/kotlin/{Ingest,OperationalWebhook}.kt",
#]
#template_dir = "kotlin/templates"
#[[kotlin.task]]
#template = "kotlin/templates/component_type.kt.jinja"
#output_dir = "kotlin/lib/src/main/kotlin/models"
#
#[[kotlin.task]]
#template = "kotlin/templates/api_resource.kt.jinja"
#output_dir = "kotlin/lib/src/main/kotlin"
[kotlin]
extra_shell_commands = [
"rm kotlin/lib/src/main/kotlin/{Ingest,OperationalWebhook}.kt",
]
template_dir = "kotlin/templates"
[[kotlin.task]]
template = "kotlin/templates/component_type.kt.jinja"
output_dir = "kotlin/lib/src/main/kotlin/models"

[[kotlin.task]]
template = "kotlin/templates/api_resource.kt.jinja"
output_dir = "kotlin/lib/src/main/kotlin"
96 changes: 96 additions & 0 deletions kotlin/lib/src/main/kotlin/IngestSource.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// this file is @generated
package com.svix.kotlin

import com.svix.kotlin.models.IngestSourceIn
import com.svix.kotlin.models.IngestSourceOut
import com.svix.kotlin.models.ListResponseIngestSourceOut
import com.svix.kotlin.models.Ordering
import com.svix.kotlin.models.RotateTokenOut
import okhttp3.Headers

data class IngestSourceListOptions(
/** 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 IngestSourceCreateOptions(val idempotencyKey: String? = null)

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

class IngestSource(private val client: SvixHttpClient) {
/** List of all the organization's Ingest Sources. */
suspend fun list(
options: IngestSourceListOptions = IngestSourceListOptions()
): ListResponseIngestSourceOut {
val url = client.newUrlBuilder().encodedPath("/ingest/api/v1/source")
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, ListResponseIngestSourceOut>("GET", url.build())
}

/** Create Ingest Source. */
suspend fun create(
ingestSourceIn: IngestSourceIn,
options: IngestSourceCreateOptions = IngestSourceCreateOptions(),
): IngestSourceOut {
val url = client.newUrlBuilder().encodedPath("/ingest/api/v1/source")
val headers = Headers.Builder()
options.idempotencyKey?.let { headers.add("idempotency-key", it) }

return client.executeRequest<IngestSourceIn, IngestSourceOut>(
"POST",
url.build(),
headers = headers.build(),
reqBody = ingestSourceIn,
)
}

/** Get an Ingest Source by id or uid. */
suspend fun get(sourceId: String): IngestSourceOut {
val url = client.newUrlBuilder().encodedPath("/ingest/api/v1/source/$sourceId")
return client.executeRequest<Any, IngestSourceOut>("GET", url.build())
}

/** Update an Ingest Source. */
suspend fun update(sourceId: String, ingestSourceIn: IngestSourceIn): IngestSourceOut {
val url = client.newUrlBuilder().encodedPath("/ingest/api/v1/source/$sourceId")

return client.executeRequest<IngestSourceIn, IngestSourceOut>(
"PUT",
url.build(),
reqBody = ingestSourceIn,
)
}

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

/**
* Rotate the Ingest Source's Url Token.
*
* This will rotate the ingest source's token, which is used to construct the unique `ingestUrl`
* for the source. Previous tokens will remain valid for 48 hours after rotation. The token can
* be rotated a maximum of three times within the 48-hour period.
*/
suspend fun rotateToken(
sourceId: String,
options: IngestSourceRotateTokenOptions = IngestSourceRotateTokenOptions(),
): RotateTokenOut {
val url = client.newUrlBuilder().encodedPath("/ingest/api/v1/source/$sourceId/token/rotate")
val headers = Headers.Builder()
options.idempotencyKey?.let { headers.add("idempotency-key", it) }
return client.executeRequest<Any, RotateTokenOut>(
"POST",
url.build(),
headers = headers.build(),
)
}
}
6 changes: 6 additions & 0 deletions kotlin/lib/src/main/kotlin/models/AdobeSignConfig.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 AdobeSignConfig(val clientId: String)
6 changes: 6 additions & 0 deletions kotlin/lib/src/main/kotlin/models/AdobeSignConfigOut.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 object AdobeSignConfigOut
22 changes: 22 additions & 0 deletions kotlin/lib/src/main/kotlin/models/ConnectorOut.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This file is @generated
package com.svix.kotlin.models

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

@Serializable
data class ConnectorOut(
val createdAt: Instant,
val description: String,
val featureFlag: String? = null,
val filterTypes: Set<String>? = null,
val id: String,
val instructions: String,
val instructionsLink: String? = null,
val kind: ConnectorKind,
val logo: String,
val name: String,
val orgId: String,
val transformation: String,
val updatedAt: Instant,
)
7 changes: 7 additions & 0 deletions kotlin/lib/src/main/kotlin/models/CronConfig.kt
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 CronConfig(val contentType: String? = null, val payload: String, val schedule: String)
6 changes: 6 additions & 0 deletions kotlin/lib/src/main/kotlin/models/DocusignConfig.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 DocusignConfig(val secret: String? = null)
6 changes: 6 additions & 0 deletions kotlin/lib/src/main/kotlin/models/DocusignConfigOut.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 object DocusignConfigOut
2 changes: 1 addition & 1 deletion kotlin/lib/src/main/kotlin/models/EnvironmentOut.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ data class EnvironmentOut(
val createdAt: Instant,
val eventTypes: List<EventTypeOut>,
@Serializable(with = StringAnyMapSerializer::class) val settings: Map<String, Any>? = null,
val transformationTemplates: List<TemplateOut>,
val transformationTemplates: List<ConnectorOut>,
val version: Long? = null,
)
6 changes: 6 additions & 0 deletions kotlin/lib/src/main/kotlin/models/GithubConfig.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 GithubConfig(val secret: String? = null)
6 changes: 6 additions & 0 deletions kotlin/lib/src/main/kotlin/models/GithubConfigOut.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 object GithubConfigOut
6 changes: 6 additions & 0 deletions kotlin/lib/src/main/kotlin/models/HubspotConfig.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 HubspotConfig(val secret: String? = null)
6 changes: 6 additions & 0 deletions kotlin/lib/src/main/kotlin/models/HubspotConfigOut.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 object HubspotConfigOut
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This file is @generated
package com.svix.kotlin.models

import kotlinx.serialization.Serializable

@Serializable
data class IngestSourceConsumerPortalAccessIn(
val expiry: ULong? = null,
val readOnly: Boolean? = null,
)
Loading