mirror of
https://github.com/hanzoai/swift-sdk.git
synced 2026-10-30 18:20:19 +00:00
The forge tree held the package scaffolding and none of the generated sources — 2,435 files of APIs, Models and Infrastructure, including BaseAPI, were simply absent, so anything depending on this copy had a package that compiled to nothing usable. Generated from the current API document rather than reconciled with the other copy: a client is a function of the spec, so regenerating answers "which history wins" without anyone having to choose. .spec-lock records which document, so the next reader can tell.
300 lines
18 KiB
Swift
300 lines
18 KiB
Swift
//
|
||
// KvAPI.swift
|
||
//
|
||
// Generated by openapi-generator
|
||
// https://openapi-generator.tech
|
||
//
|
||
|
||
import Foundation
|
||
|
||
open class KvAPI {
|
||
|
||
/**
|
||
Removes one bucket of the caller's org — every key and every revision with it — and answers 204 with no body.
|
||
|
||
- parameter bucket: (path) Bucket is the bucket's name, from the path.
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: Void
|
||
*/
|
||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||
open class func deleteKvByBucket(bucket: String, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) async throws(ErrorResponse) {
|
||
return try await deleteKvByBucketWithRequestBuilder(bucket: bucket, apiConfiguration: apiConfiguration).execute().body
|
||
}
|
||
|
||
/**
|
||
Removes one bucket of the caller's org — every key and every revision with it — and answers 204 with no body.
|
||
- DELETE /v1/kv/{bucket}
|
||
- Removes one bucket of the caller's org — every key and every revision with it — and answers 204 with no body. 404 when the org has no bucket of that name.
|
||
- Bearer Token:
|
||
- type: http
|
||
- name: bearer
|
||
- parameter bucket: (path) Bucket is the bucket's name, from the path.
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: RequestBuilder<Void>
|
||
*/
|
||
open class func deleteKvByBucketWithRequestBuilder(bucket: String, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) -> RequestBuilder<Void> {
|
||
var localVariablePath = "/v1/kv/{bucket}"
|
||
let bucketPreEscape = "\(APIHelper.mapValueToPathItem(bucket))"
|
||
let bucketPostEscape = bucketPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||
localVariablePath = localVariablePath.replacingOccurrences(of: "{bucket}", with: bucketPostEscape, options: .literal, range: nil)
|
||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||
let localVariableParameters: [String: any Sendable]? = nil
|
||
|
||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||
|
||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||
:
|
||
]
|
||
|
||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||
|
||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = apiConfiguration.requestBuilderFactory.getNonDecodableBuilder()
|
||
|
||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, apiConfiguration: apiConfiguration)
|
||
}
|
||
|
||
/**
|
||
Delete removes one key — a delete marker in the key's history, so watchers see it and Get answers 404 — and answers 204 with no body.
|
||
|
||
- parameter bucket: (path) Bucket is the bucket, from the path.
|
||
- parameter key: (path) Key is the key, from the path.
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: Void
|
||
*/
|
||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||
open class func deleteKvByBucketByKey(bucket: String, key: String, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) async throws(ErrorResponse) {
|
||
return try await deleteKvByBucketByKeyWithRequestBuilder(bucket: bucket, key: key, apiConfiguration: apiConfiguration).execute().body
|
||
}
|
||
|
||
/**
|
||
Delete removes one key — a delete marker in the key's history, so watchers see it and Get answers 404 — and answers 204 with no body.
|
||
- DELETE /v1/kv/{bucket}/{key}
|
||
- Delete removes one key — a delete marker in the key's history, so watchers see it and Get answers 404 — and answers 204 with no body. 404 when the bucket does not exist.
|
||
- Bearer Token:
|
||
- type: http
|
||
- name: bearer
|
||
- parameter bucket: (path) Bucket is the bucket, from the path.
|
||
- parameter key: (path) Key is the key, from the path.
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: RequestBuilder<Void>
|
||
*/
|
||
open class func deleteKvByBucketByKeyWithRequestBuilder(bucket: String, key: String, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) -> RequestBuilder<Void> {
|
||
var localVariablePath = "/v1/kv/{bucket}/{key}"
|
||
let bucketPreEscape = "\(APIHelper.mapValueToPathItem(bucket))"
|
||
let bucketPostEscape = bucketPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||
localVariablePath = localVariablePath.replacingOccurrences(of: "{bucket}", with: bucketPostEscape, options: .literal, range: nil)
|
||
let keyPreEscape = "\(APIHelper.mapValueToPathItem(key))"
|
||
let keyPostEscape = keyPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||
localVariablePath = localVariablePath.replacingOccurrences(of: "{key}", with: keyPostEscape, options: .literal, range: nil)
|
||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||
let localVariableParameters: [String: any Sendable]? = nil
|
||
|
||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||
|
||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||
:
|
||
]
|
||
|
||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||
|
||
let localVariableRequestBuilder: RequestBuilder<Void>.Type = apiConfiguration.requestBuilderFactory.getNonDecodableBuilder()
|
||
|
||
return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, apiConfiguration: apiConfiguration)
|
||
}
|
||
|
||
/**
|
||
Get returns one key's current value and revision.
|
||
|
||
- parameter bucket: (path) Bucket is the bucket, from the path.
|
||
- parameter key: (path) Key is the key, from the path.
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: KvEntry
|
||
*/
|
||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||
open class func getKvByBucketByKey(bucket: String, key: String, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) async throws(ErrorResponse) -> KvEntry {
|
||
return try await getKvByBucketByKeyWithRequestBuilder(bucket: bucket, key: key, apiConfiguration: apiConfiguration).execute().body
|
||
}
|
||
|
||
/**
|
||
Get returns one key's current value and revision.
|
||
- GET /v1/kv/{bucket}/{key}
|
||
- Get returns one key's current value and revision. 404 when the bucket does not exist, the key was never written, or its latest revision is a delete.
|
||
- Bearer Token:
|
||
- type: http
|
||
- name: bearer
|
||
- parameter bucket: (path) Bucket is the bucket, from the path.
|
||
- parameter key: (path) Key is the key, from the path.
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: RequestBuilder<KvEntry>
|
||
*/
|
||
open class func getKvByBucketByKeyWithRequestBuilder(bucket: String, key: String, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) -> RequestBuilder<KvEntry> {
|
||
var localVariablePath = "/v1/kv/{bucket}/{key}"
|
||
let bucketPreEscape = "\(APIHelper.mapValueToPathItem(bucket))"
|
||
let bucketPostEscape = bucketPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||
localVariablePath = localVariablePath.replacingOccurrences(of: "{bucket}", with: bucketPostEscape, options: .literal, range: nil)
|
||
let keyPreEscape = "\(APIHelper.mapValueToPathItem(key))"
|
||
let keyPostEscape = keyPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||
localVariablePath = localVariablePath.replacingOccurrences(of: "{key}", with: keyPostEscape, options: .literal, range: nil)
|
||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||
let localVariableParameters: [String: any Sendable]? = nil
|
||
|
||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||
|
||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||
:
|
||
]
|
||
|
||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||
|
||
let localVariableRequestBuilder: RequestBuilder<KvEntry>.Type = apiConfiguration.requestBuilderFactory.getBuilder()
|
||
|
||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, apiConfiguration: apiConfiguration)
|
||
}
|
||
|
||
/**
|
||
History returns one key's retained revisions, oldest first — every put and every delete marker up to the bucket's History depth.
|
||
|
||
- parameter bucket: (path) Bucket is the bucket, from the path.
|
||
- parameter key: (path) Key is the key, from the path.
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: KvPage
|
||
*/
|
||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||
open class func getKvByBucketByKeyHistory(bucket: String, key: String, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) async throws(ErrorResponse) -> KvPage {
|
||
return try await getKvByBucketByKeyHistoryWithRequestBuilder(bucket: bucket, key: key, apiConfiguration: apiConfiguration).execute().body
|
||
}
|
||
|
||
/**
|
||
History returns one key's retained revisions, oldest first — every put and every delete marker up to the bucket's History depth.
|
||
- GET /v1/kv/{bucket}/{key}/history
|
||
- History returns one key's retained revisions, oldest first — every put and every delete marker up to the bucket's History depth. 404 when the bucket does not exist or the key was never written.
|
||
- Bearer Token:
|
||
- type: http
|
||
- name: bearer
|
||
- parameter bucket: (path) Bucket is the bucket, from the path.
|
||
- parameter key: (path) Key is the key, from the path.
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: RequestBuilder<KvPage>
|
||
*/
|
||
open class func getKvByBucketByKeyHistoryWithRequestBuilder(bucket: String, key: String, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) -> RequestBuilder<KvPage> {
|
||
var localVariablePath = "/v1/kv/{bucket}/{key}/history"
|
||
let bucketPreEscape = "\(APIHelper.mapValueToPathItem(bucket))"
|
||
let bucketPostEscape = bucketPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||
localVariablePath = localVariablePath.replacingOccurrences(of: "{bucket}", with: bucketPostEscape, options: .literal, range: nil)
|
||
let keyPreEscape = "\(APIHelper.mapValueToPathItem(key))"
|
||
let keyPostEscape = keyPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||
localVariablePath = localVariablePath.replacingOccurrences(of: "{key}", with: keyPostEscape, options: .literal, range: nil)
|
||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||
let localVariableParameters: [String: any Sendable]? = nil
|
||
|
||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||
|
||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||
:
|
||
]
|
||
|
||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||
|
||
let localVariableRequestBuilder: RequestBuilder<KvPage>.Type = apiConfiguration.requestBuilderFactory.getBuilder()
|
||
|
||
return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, apiConfiguration: apiConfiguration)
|
||
}
|
||
|
||
/**
|
||
Creates a KV bucket and returns it.
|
||
|
||
- parameter bucket: (path) Bucket is the bucket's name within the org, from the path: 1–64 of [A-Za-z0-9_], no dash.
|
||
- parameter bucketWrite: (body)
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: BucketRecord
|
||
*/
|
||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||
open class func postKvByBucket(bucket: String, bucketWrite: BucketWrite, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) async throws(ErrorResponse) -> BucketRecord {
|
||
return try await postKvByBucketWithRequestBuilder(bucket: bucket, bucketWrite: bucketWrite, apiConfiguration: apiConfiguration).execute().body
|
||
}
|
||
|
||
/**
|
||
Creates a KV bucket and returns it.
|
||
- POST /v1/kv/{bucket}
|
||
- Creates a KV bucket and returns it. A bucket is keyed state on the same durable plane as the streams: each key holds up to History revisions, entries can expire by TTL, and watchers on the NATS port see every write. 409 when the org already has a bucket of that name.
|
||
- Bearer Token:
|
||
- type: http
|
||
- name: bearer
|
||
- parameter bucket: (path) Bucket is the bucket's name within the org, from the path: 1–64 of [A-Za-z0-9_], no dash.
|
||
- parameter bucketWrite: (body)
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: RequestBuilder<BucketRecord>
|
||
*/
|
||
open class func postKvByBucketWithRequestBuilder(bucket: String, bucketWrite: BucketWrite, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) -> RequestBuilder<BucketRecord> {
|
||
var localVariablePath = "/v1/kv/{bucket}"
|
||
let bucketPreEscape = "\(APIHelper.mapValueToPathItem(bucket))"
|
||
let bucketPostEscape = bucketPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||
localVariablePath = localVariablePath.replacingOccurrences(of: "{bucket}", with: bucketPostEscape, options: .literal, range: nil)
|
||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: bucketWrite, codableHelper: apiConfiguration.codableHelper)
|
||
|
||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||
|
||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||
"Content-Type": "application/json",
|
||
]
|
||
|
||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||
|
||
let localVariableRequestBuilder: RequestBuilder<BucketRecord>.Type = apiConfiguration.requestBuilderFactory.getBuilder()
|
||
|
||
return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, apiConfiguration: apiConfiguration)
|
||
}
|
||
|
||
/**
|
||
Put sets one key to one value and returns the revision the write created.
|
||
|
||
- parameter bucket: (path) Bucket is the bucket, from the path.
|
||
- parameter key: (path) Key is the key, from the path.
|
||
- parameter kvWrite: (body)
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: KvAck
|
||
*/
|
||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||
open class func putKvByBucketByKey(bucket: String, key: String, kvWrite: KvWrite, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) async throws(ErrorResponse) -> KvAck {
|
||
return try await putKvByBucketByKeyWithRequestBuilder(bucket: bucket, key: key, kvWrite: kvWrite, apiConfiguration: apiConfiguration).execute().body
|
||
}
|
||
|
||
/**
|
||
Put sets one key to one value and returns the revision the write created.
|
||
- PUT /v1/kv/{bucket}/{key}
|
||
- Put sets one key to one value and returns the revision the write created. Writes are versioned: each put is a new revision and the bucket retains up to its History of them per key.
|
||
- Bearer Token:
|
||
- type: http
|
||
- name: bearer
|
||
- parameter bucket: (path) Bucket is the bucket, from the path.
|
||
- parameter key: (path) Key is the key, from the path.
|
||
- parameter kvWrite: (body)
|
||
- parameter apiConfiguration: The configuration for the http request.
|
||
- returns: RequestBuilder<KvAck>
|
||
*/
|
||
open class func putKvByBucketByKeyWithRequestBuilder(bucket: String, key: String, kvWrite: KvWrite, apiConfiguration: HanzoAPIConfiguration = HanzoAPIConfiguration.shared) -> RequestBuilder<KvAck> {
|
||
var localVariablePath = "/v1/kv/{bucket}/{key}"
|
||
let bucketPreEscape = "\(APIHelper.mapValueToPathItem(bucket))"
|
||
let bucketPostEscape = bucketPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||
localVariablePath = localVariablePath.replacingOccurrences(of: "{bucket}", with: bucketPostEscape, options: .literal, range: nil)
|
||
let keyPreEscape = "\(APIHelper.mapValueToPathItem(key))"
|
||
let keyPostEscape = keyPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||
localVariablePath = localVariablePath.replacingOccurrences(of: "{key}", with: keyPostEscape, options: .literal, range: nil)
|
||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: kvWrite, codableHelper: apiConfiguration.codableHelper)
|
||
|
||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||
|
||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||
"Content-Type": "application/json",
|
||
]
|
||
|
||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||
|
||
let localVariableRequestBuilder: RequestBuilder<KvAck>.Type = apiConfiguration.requestBuilderFactory.getBuilder()
|
||
|
||
return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: true, apiConfiguration: apiConfiguration)
|
||
}
|
||
}
|