public New ( string description, ApiKeyType type = ApiKeyType.Backend, string roleId = null ) : Task |
||
description | string | Description of new API client. |
type | ApiKeyType | Type of new API client. |
roleId | string | New API client's permission role id (see role.get()). Not used when creating User API key (type = user) |
return | Task |
public Task<ApiKey> New(string description, ApiKeyType type = ApiKeyType.Backend, string roleId = null)
{
if(description == null)
throw new ArgumentNullException();
if(type == ApiKeyType.User && roleId != null)
throw new ArgumentException();
return _syncanoClient.PostAsync<ApiKey>("apikey.new", new {description, type = type.ToString(), role_id = roleId}, "apikey");
}
public async Task New_BackendType_CreatesNewApiKey(ApiKeySyncanoClient client) { //given var description = "apiKey description"; //when var apiKey = await client.New(description, ApiKeyType.Backend, TestData.RoleId); //then apiKey.ShouldNotBeNull(); apiKey.Description.ShouldEqual(description); //cleanup await client.Delete(apiKey.Id); }