Skip to main content

ApiKeysAPI

MethodHTTP requestDescription
createApiKeyPOST /api_keysCreate new api key for current user
deleteApiKeyDELETE /api_keys/{id}Delete provided api key
listApiKeysGET /api_keysLoad api keys for user

createApiKey#

Create new api key for current user Requires scope CreateApiKey. When query param user_id is provided requires admin role.

Request with Combine's publisher:#

public func createApiKeyPublisher(body: CreateApiKeyBody, userId: UUID?) -> AnyPublisher<DisplayApiKey, APIError>

Example:#

import YatLib
let body = CreateApiKeyBody(name: "name_example", expiresAt: Date(), scopes: ["scopes_example"]) // CreateApiKeyBody | let userId = 987 // UUID | User id for which api key should be applied (optional)var cancelables = Set<AnyCancellable>()
Yat.api.apiKeys.createApiKeyPublisher(body: body, userId: userId)    .sink(        receiveCompletion: { [weak self] in /* Handle completion/failure */ },        receiveValue: { /* Handle response */ }    )    .store(in: &cancelables)

Request with closure:#

public func createApiKey(body: CreateApiKeyBody, userId: UUID?, result: @escaping (Result<DisplayApiKey, APIError>) -> Void)

Example#

import YatLib
let body = CreateApiKeyBody(name: "name_example", expiresAt: Date(), scopes: ["scopes_example"]) // CreateApiKeyBody | let userId = 987 // UUID | User id for which api key should be applied (optional)
Yat.api.apiKeys.createApiKey(body: CreateApiKeyBody, userId: UUID? { result in    switch result {        case let .success(model):        // Handle response        case let .failure(error):        // Handle failure    }}

Parameters#

NameTypeDescriptionNotes
bodyCreateApiKeyBody
userIdUUIDUser id for which api key should be applied[optional]

Return type#

DisplayApiKey

Authorization#

two_factor

[Back to top] [Back to API list] [Back to Model list] [Back to index]

deleteApiKey#

Delete provided api key When key does not belong to current user requires Admin access

Request with Combine's publisher:#

public func deleteApiKeyPublisher(id: String) -> AnyPublisher<DisplayApiKey, APIError>

Example:#

import YatLib
let id = "id_example" // String | var cancelables = Set<AnyCancellable>()
Yat.api.apiKeys.deleteApiKeyPublisher(id: id)    .sink(        receiveCompletion: { [weak self] in /* Handle completion/failure */ },        receiveValue: { /* Handle response */ }    )    .store(in: &cancelables)

Request with closure:#

public func deleteApiKey(id: String, result: @escaping (Result<DisplayApiKey, APIError>) -> Void)

Example#

import YatLib
let id = "id_example" // String | 
Yat.api.apiKeys.deleteApiKey(id: String { result in    switch result {        case let .success(model):        // Handle response        case let .failure(error):        // Handle failure    }}

Parameters#

NameTypeDescriptionNotes
idString

Return type#

DisplayApiKey

Authorization#

two_factor

[Back to top] [Back to API list] [Back to Model list] [Back to index]

listApiKeys#

Load api keys for user If query param user_id is provided requires admin role.

Request with Combine's publisher:#

public func listApiKeysPublisher(userId: UUID?) -> AnyPublisher<[DisplayApiKey], APIError>

Example:#

import YatLib
let userId = 987 // UUID | User id for which api key should be applied (optional)var cancelables = Set<AnyCancellable>()
Yat.api.apiKeys.listApiKeysPublisher(userId: userId)    .sink(        receiveCompletion: { [weak self] in /* Handle completion/failure */ },        receiveValue: { /* Handle response */ }    )    .store(in: &cancelables)

Request with closure:#

public func listApiKeys(userId: UUID?, result: @escaping (Result<[DisplayApiKey], APIError>) -> Void)

Example#

import YatLib
let userId = 987 // UUID | User id for which api key should be applied (optional)
Yat.api.apiKeys.listApiKeys(userId: UUID? { result in    switch result {        case let .success(model):        // Handle response        case let .failure(error):        // Handle failure    }}

Parameters#

NameTypeDescriptionNotes
userIdUUIDUser id for which api key should be applied[optional]

Return type#

[DisplayApiKey]

Authorization#

two_factor

[Back to top] [Back to API list] [Back to Model list] [Back to index]