ApiKeysAPI
| Method | HTTP request | Description |
|---|---|---|
| createApiKey | POST /api_keys | Create new api key for current user |
| deleteApiKey | DELETE /api_keys/{id} | Delete provided api key |
| listApiKeys | GET /api_keys | Load 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#
| Name | Type | Description | Notes |
|---|---|---|---|
| body | CreateApiKeyBody | ||
| userId | UUID | User id for which api key should be applied | [optional] |
Return type#
Authorization#
[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#
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String |
Return type#
Authorization#
[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#
| Name | Type | Description | Notes |
|---|---|---|---|
| userId | UUID | User id for which api key should be applied | [optional] |
Return type#
Authorization#
[Back to top] [Back to API list] [Back to Model list] [Back to index]