Beispiel #1
0
        public async Task DeleteDatasetAsync(string datasetName)
        {
            if (string.IsNullOrWhiteSpace(datasetName))
            {
                throw new KeenException("A dataset name is required.");
            }

            if (string.IsNullOrWhiteSpace(_masterKey))
            {
                throw new KeenException("An API MasterKey is required to get dataset results.");
            }

            var responseMsg = await _keenHttpClient
                              .DeleteAsync(GetDatasetUrl(datasetName), _masterKey)
                              .ConfigureAwait(continueOnCapturedContext: false);

            var responseString = await responseMsg
                                 .Content
                                 .ReadAsStringAsync()
                                 .ConfigureAwait(continueOnCapturedContext: false);

            if (HttpStatusCode.NoContent != responseMsg.StatusCode)
            {
                var response = JObject.Parse(responseString);

                KeenUtil.CheckApiErrorCode(response);

                throw new KeenException($"Request failed with status: {responseMsg.StatusCode}");
            }
        }
Beispiel #2
0
        public async Task DeleteCollection(string collection)
        {
            if (string.IsNullOrWhiteSpace(_masterKey))
            {
                throw new KeenException("An API MasterKey is required to delete a collection.");
            }

            var responseMsg = await _keenHttpClient
                              .DeleteAsync(GetCollectionUrl(collection), _masterKey)
                              .ConfigureAwait(continueOnCapturedContext: false);

            if (!responseMsg.IsSuccessStatusCode)
            {
                throw new KeenException("DeleteCollection failed with status: " + responseMsg.StatusCode);
            }
        }