All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.svix.kotlin.internal.apis.ApplicationApi.kt Maven / Gradle / Ivy

/**
* Svix API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.1.1
* 
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.svix.kotlin.internal.apis

import com.svix.kotlin.models.ApplicationIn
import com.svix.kotlin.models.ApplicationOut
import com.svix.kotlin.models.ApplicationPatch
import com.svix.kotlin.models.ApplicationStats
import com.svix.kotlin.models.HTTPValidationError
import com.svix.kotlin.models.HttpErrorOut
import com.svix.kotlin.models.ListResponseApplicationOut
import com.svix.kotlin.models.ListResponseApplicationStats
import com.svix.kotlin.models.Ordering

import com.svix.kotlin.internal.infrastructure.ApiClient
import com.svix.kotlin.internal.infrastructure.ClientException
import com.svix.kotlin.internal.infrastructure.ClientError
import com.svix.kotlin.internal.infrastructure.ServerException
import com.svix.kotlin.internal.infrastructure.ServerError
import com.svix.kotlin.internal.infrastructure.MultiValueMap
import com.svix.kotlin.internal.infrastructure.RequestConfig
import com.svix.kotlin.internal.infrastructure.RequestMethod
import com.svix.kotlin.internal.infrastructure.ResponseType
import com.svix.kotlin.internal.infrastructure.Success
import com.svix.kotlin.internal.infrastructure.toMultiValue

class ApplicationApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
    companion object {
        @JvmStatic
        val defaultBasePath: String by lazy {
            System.getProperties().getProperty("com.svix.kotlin.internal.baseUrl", "https://api.eu.svix.com")
        }
    }

    /**
    * Get App Usage Stats
    * Get basic statistics for all applications.
    * @param since Filter the range to data after this date 
    * @param until Filter the range to data before this date 
    * @param limit Limit the number of returned items (optional, default to 50)
    * @param iterator The iterator to use (depends on the chosen ordering) (optional)
    * @return ListResponseApplicationStats
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Suppress("UNCHECKED_CAST")
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun getAppUsageStatsApiV1AppStatsUsageGet(since: java.time.OffsetDateTime, until: java.time.OffsetDateTime, limit: kotlin.Int?, iterator: kotlin.String?) : ListResponseApplicationStats {
        val localVariableConfig = getAppUsageStatsApiV1AppStatsUsageGetRequestConfig(since = since, until = until, limit = limit, iterator = iterator)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as ListResponseApplicationStats
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation getAppUsageStatsApiV1AppStatsUsageGet
    *
    * @param since Filter the range to data after this date 
    * @param until Filter the range to data before this date 
    * @param limit Limit the number of returned items (optional, default to 50)
    * @param iterator The iterator to use (depends on the chosen ordering) (optional)
    * @return RequestConfig
    */
    fun getAppUsageStatsApiV1AppStatsUsageGetRequestConfig(since: java.time.OffsetDateTime, until: java.time.OffsetDateTime, limit: kotlin.Int?, iterator: kotlin.String?) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf>()
            .apply {
                put("since", listOf(parseDateToQueryString(since)))
                put("until", listOf(parseDateToQueryString(until)))
                if (limit != null) {
                    put("limit", listOf(limit.toString()))
                }
                if (iterator != null) {
                    put("iterator", listOf(iterator.toString()))
                }
            }
        val localVariableHeaders: MutableMap = mutableMapOf()

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/api/v1/app/stats/usage",
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Create Application
    * Create a new application.
    * @param applicationIn  
    * @param getIfExists Get an existing application, or create a new one if doesn't exist. It's two separate functions in the libs. (optional, default to false)
    * @param idempotencyKey The request's idempotency key (optional)
    * @return ApplicationOut
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Suppress("UNCHECKED_CAST")
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1ApplicationCreate(applicationIn: ApplicationIn, getIfExists: kotlin.Boolean?, idempotencyKey: kotlin.String?) : ApplicationOut {
        val localVariableConfig = v1ApplicationCreateRequestConfig(applicationIn = applicationIn, getIfExists = getIfExists, idempotencyKey = idempotencyKey)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as ApplicationOut
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1ApplicationCreate
    *
    * @param applicationIn  
    * @param getIfExists Get an existing application, or create a new one if doesn't exist. It's two separate functions in the libs. (optional, default to false)
    * @param idempotencyKey The request's idempotency key (optional)
    * @return RequestConfig
    */
    fun v1ApplicationCreateRequestConfig(applicationIn: ApplicationIn, getIfExists: kotlin.Boolean?, idempotencyKey: kotlin.String?) : RequestConfig {
        val localVariableBody = applicationIn
        val localVariableQuery: MultiValueMap = mutableMapOf>()
            .apply {
                if (getIfExists != null) {
                    put("get_if_exists", listOf(getIfExists.toString()))
                }
            }
        val localVariableHeaders: MutableMap = mutableMapOf()
        idempotencyKey?.apply { localVariableHeaders["idempotency-key"] = this.toString() }

        return RequestConfig(
            method = RequestMethod.POST,
            path = "/api/v1/app",
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Delete Application
    * Delete an application.
    * @param appId The app's ID or UID 
    * @return void
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1ApplicationDelete(appId: kotlin.String) : Unit {
        val localVariableConfig = v1ApplicationDeleteRequestConfig(appId = appId)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> Unit
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1ApplicationDelete
    *
    * @param appId The app's ID or UID 
    * @return RequestConfig
    */
    fun v1ApplicationDeleteRequestConfig(appId: kotlin.String) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()

        return RequestConfig(
            method = RequestMethod.DELETE,
            path = "/api/v1/app/{app_id}".replace("{"+"app_id"+"}", "$appId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Get Application
    * Get an application.
    * @param appId The app's ID or UID 
    * @return ApplicationOut
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Suppress("UNCHECKED_CAST")
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1ApplicationGet(appId: kotlin.String) : ApplicationOut {
        val localVariableConfig = v1ApplicationGetRequestConfig(appId = appId)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as ApplicationOut
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1ApplicationGet
    *
    * @param appId The app's ID or UID 
    * @return RequestConfig
    */
    fun v1ApplicationGetRequestConfig(appId: kotlin.String) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/api/v1/app/{app_id}".replace("{"+"app_id"+"}", "$appId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Get App Stats
    * Get basic statistics for the application
    * @param appId The app's ID or UID 
    * @param since Filter the range to data starting from this date 
    * @param until Filter the range to data ending by this date 
    * @return ApplicationStats
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Suppress("UNCHECKED_CAST")
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1ApplicationGetStats(appId: kotlin.String, since: java.time.OffsetDateTime, until: java.time.OffsetDateTime) : ApplicationStats {
        val localVariableConfig = v1ApplicationGetStatsRequestConfig(appId = appId, since = since, until = until)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as ApplicationStats
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1ApplicationGetStats
    *
    * @param appId The app's ID or UID 
    * @param since Filter the range to data starting from this date 
    * @param until Filter the range to data ending by this date 
    * @return RequestConfig
    */
    fun v1ApplicationGetStatsRequestConfig(appId: kotlin.String, since: java.time.OffsetDateTime, until: java.time.OffsetDateTime) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf>()
            .apply {
                put("since", listOf(parseDateToQueryString(since)))
                put("until", listOf(parseDateToQueryString(until)))
            }
        val localVariableHeaders: MutableMap = mutableMapOf()

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/api/v1/app/{app_id}/stats".replace("{"+"app_id"+"}", "$appId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * List Applications
    * List of all the organization's applications.
    * @param limit Limit the number of returned items (optional)
    * @param iterator The iterator returned from a prior invocation (optional)
    * @param order The sorting order of the returned items (optional)
    * @return ListResponseApplicationOut
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Suppress("UNCHECKED_CAST")
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1ApplicationList(limit: kotlin.Int?, iterator: kotlin.String?, order: Ordering?) : ListResponseApplicationOut {
        val localVariableConfig = v1ApplicationListRequestConfig(limit = limit, iterator = iterator, order = order)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as ListResponseApplicationOut
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1ApplicationList
    *
    * @param limit Limit the number of returned items (optional)
    * @param iterator The iterator returned from a prior invocation (optional)
    * @param order The sorting order of the returned items (optional)
    * @return RequestConfig
    */
    fun v1ApplicationListRequestConfig(limit: kotlin.Int?, iterator: kotlin.String?, order: Ordering?) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf>()
            .apply {
                if (limit != null) {
                    put("limit", listOf(limit.toString()))
                }
                if (iterator != null) {
                    put("iterator", listOf(iterator.toString()))
                }
                if (order != null) {
                    put("order", listOf(order.toString()))
                }
            }
        val localVariableHeaders: MutableMap = mutableMapOf()

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/api/v1/app",
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Patch Application
    * Partially update an application.
    * @param appId The app's ID or UID 
    * @param applicationPatch  
    * @return ApplicationOut
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Suppress("UNCHECKED_CAST")
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1ApplicationPatch(appId: kotlin.String, applicationPatch: ApplicationPatch) : ApplicationOut {
        val localVariableConfig = v1ApplicationPatchRequestConfig(appId = appId, applicationPatch = applicationPatch)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as ApplicationOut
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1ApplicationPatch
    *
    * @param appId The app's ID or UID 
    * @param applicationPatch  
    * @return RequestConfig
    */
    fun v1ApplicationPatchRequestConfig(appId: kotlin.String, applicationPatch: ApplicationPatch) : RequestConfig {
        val localVariableBody = applicationPatch
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()

        return RequestConfig(
            method = RequestMethod.PATCH,
            path = "/api/v1/app/{app_id}".replace("{"+"app_id"+"}", "$appId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Update Application
    * Update an application.
    * @param appId The app's ID or UID 
    * @param applicationIn  
    * @return ApplicationOut
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Suppress("UNCHECKED_CAST")
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1ApplicationUpdate(appId: kotlin.String, applicationIn: ApplicationIn) : ApplicationOut {
        val localVariableConfig = v1ApplicationUpdateRequestConfig(appId = appId, applicationIn = applicationIn)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as ApplicationOut
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1ApplicationUpdate
    *
    * @param appId The app's ID or UID 
    * @param applicationIn  
    * @return RequestConfig
    */
    fun v1ApplicationUpdateRequestConfig(appId: kotlin.String, applicationIn: ApplicationIn) : RequestConfig {
        val localVariableBody = applicationIn
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()

        return RequestConfig(
            method = RequestMethod.PUT,
            path = "/api/v1/app/{app_id}".replace("{"+"app_id"+"}", "$appId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy