예제 #1
0
        /// <summary>
        /// Creates a new database.
        /// (Only possible from within the _system database)
        /// </summary>
        /// <param name="request">The parameters required by this endpoint.</param>
        /// <returns></returns>
        public async Task <PostDatabaseResponse> PostDatabaseAsync(PostDatabaseBody request)
        {
            var content = GetStringContent(request, true, true);

            using (var response = await _client.PostAsync(_databaseApiPath, content))
            {
                if (response.IsSuccessStatusCode)
                {
                    var stream = await response.Content.ReadAsStreamAsync();

                    return(DeserializeJsonFromStream <PostDatabaseResponse>(stream));
                }
                throw await GetApiErrorException(response);
            }
        }
예제 #2
0
        /// <summary>
        /// Creates a new database.
        /// (Only possible from within the _system database)
        /// </summary>
        /// <param name="request">The parameters required by this endpoint.</param>
        /// <returns></returns>
        public virtual async Task <PostDatabaseResponse> PostDatabaseAsync(PostDatabaseBody request)
        {
            var content = GetContent(request, new ApiClientSerializationOptions(true, true));

            using (var response = await _client.PostAsync(_databaseApiPath, content).ConfigureAwait(false))
            {
                if (response.IsSuccessStatusCode)
                {
                    var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);

                    return(DeserializeJsonFromStream <PostDatabaseResponse>(stream));
                }
                throw await GetApiErrorException(response).ConfigureAwait(false);
            }
        }
 /// <summary>
 /// Creates a new database.
 /// (Only possible from within the _system database)
 /// </summary>
 /// <param name="request">The parameters required by this endpoint.</param>
 /// <returns></returns>
 public virtual async Task <PostDatabaseResponse> PostDatabaseAsync(PostDatabaseBody request, CancellationToken cancellationToken = default)
 {
     return(await PostRequestAsync(ApiRootPath, response => new PostDatabaseResponse(response), request, null,
                                   cancellationToken));
 }