/// <summary> /// Allows to enable or disable an API key. /// </summary> /// <param name="id">ID of the key to update the status for.</param> /// <param name="isEnabled">Whether the key is supposed to be enabled.</param> /// <exception cref="ApiKeyNotFoundException">Thrown if no matching API key could be found.</exception> public void UpdateApiKeyStatus(Guid id, bool isEnabled) { ApiKey key = GetApiKeyOrThrowNotFoundException(id); key.Enabled = isEnabled; ApiKeyRepository.UpdateApiKey(key); }
/// <summary> /// Allows to enable or disable an API key. /// </summary> /// <param name="id">ID of the key to update the status for.</param> /// <param name="isEnabled">Whether the key is supposed to be enabled.</param> /// <exception cref="EntityNotFoundException">Thrown if no matching API key could be found.</exception> public async Task UpdateApiKeyStatus(Guid id, bool isEnabled) { ApiKey key = await GetApiKey(id); key.Enabled = isEnabled; await ApiKeyRepository.UpdateApiKey(key); }
/// <summary> /// Updates an API key, which allows to change it's name. /// </summary> /// <param name="id">ID of the key to update.</param> /// <param name="name">New name of the key.</param> /// <returns>Returns the updated key.</returns> /// <exception cref="EntityNotFoundException">Thrown if no matching API key could be found.</exception> public async Task <ApiKey> UpdateApiKey(Guid id, string name) { ApiKey key = await GetApiKey(id); key.Name = name; await ApiKeyRepository.UpdateApiKey(key); return(key); }
/// <summary> /// Updates an API key, which allows to change it's name and set the rights granted to this key. /// </summary> /// <param name="id">ID of the key to update.</param> /// <param name="name">New name of the key.</param> /// <param name="rights">Rights to grant to the key.</param> /// <returns>Returns the updated key.</returns> /// <exception cref="ApiKeyNotFoundException">Thrown if no matching API key could be found.</exception> public ApiKey UpdateApiKey(Guid id, string name, ICollection <Right> rights) { ApiKey key = GetApiKeyOrThrowNotFoundException(id); key.Name = name; key.Rights = rights; ApiKeyRepository.UpdateApiKey(key); return(key); }