public void CreateAssetDatabase() { AssetDatabase test = new AssetDatabase { Name = "New Database", Description = "Hello world" }; api.CreateAssetDatabase(Resource.WebIdAssetServer, test); string webId = client.ResponseHeaders["Location"]; string expectedResponse = httpClient.GetAsync(webId) .Result.Content .ReadAsStringAsync().Result; AssetDatabase expected = JsonConvert.DeserializeObject<AssetDatabase>(expectedResponse); Assert.True(String.Equals(test.Name, expected.Name, StringComparison.InvariantCultureIgnoreCase)); Assert.True(String.Equals(test.Description, expected.Description, StringComparison.InvariantCultureIgnoreCase)); HttpResponseMessage response = httpClient.DeleteAsync(webId).Result; }
/// <summary> /// Update an asset database by replacing items in its definition. /// </summary> /// <param name="webId">The ID of the database.</param> /// <param name="body">A partial database containing the desired changes.</param> /// <returns></returns> public async System.Threading.Tasks.Task UpdateAssetDatabaseAsync (string webId, AssetDatabase body) { // verify the required parameter 'webId' is set if (webId == null) throw new ApiException(400, "Missing required parameter 'webId' when calling UpdateAssetDatabase"); // verify the required parameter 'body' is set if (body == null) throw new ApiException(400, "Missing required parameter 'body' when calling UpdateAssetDatabase"); var path_ = "/assetdatabases/{webId}"; var pathParams = new Dictionary<String, String>(); var queryParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>(); var fileParams = new Dictionary<String, FileParameter>(); String postBody = null; // to determine the Accept header String[] http_header_accepts = new String[] { "application/json" }; String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); if (webId != null) pathParams.Add("webId", ApiClient.ParameterToString(webId)); // path parameter postBody = ApiClient.Serialize(body); // http body (model) parameter // authentication setting, if any String[] authSettings = new String[] { }; // make the HTTP request IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.PATCH, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); if (((int)response.StatusCode) >= 400) throw new ApiException ((int)response.StatusCode, "Error calling UpdateAssetDatabase: " + response.Content, response.Content); return; }