/// <summary> /// /// </summary> /// <remarks> /// Gets the event type on the format needed by the REST request. /// </remarks> /// <exception cref="Autodesk.Forge.Client.ApiException">Thrown when passing unimplemented type.</exception> /// <param name="webhookEvent">The webhook event type to get as string for REST request.</param> /// <returns>Task of ApiResponse (webhooks)</returns> private string EventEnumToString(DerivativeWebhookEvent webhookEvent) { switch (webhookEvent) { case DerivativeWebhookEvent.ExtractionFinished: return("extraction.finished"); default: throw new ApiException(400, "Webhook event type {webhookEvent} is not implemented."); } }
/// <summary> /// /// </summary> /// <remarks> /// Deletes the webhook with the given GUID for the given model derivative event. /// </remarks> /// <exception cref="Autodesk.Forge.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="eventType">The webhook event type to delete hook for.</param> /// <param name="hookId">The GUID of the hook to delete.</param> /// <returns>Task of ApiResponse (webhooks)</returns> public async System.Threading.Tasks.Task <ApiResponse <dynamic> > DeleteHookAsyncWithHttpInfo(DerivativeWebhookEvent eventType, Guid hookId) { // verify the required parameter 'hookId' is set if (hookId == Guid.Empty) { throw new ApiException(400, "Missing required parameter 'hookId' when calling DerivativeWebhooksApi->DeleteHookAsync"); } var enumAsString = EventEnumToString(eventType); var localVarPath = "/webhooks/v1/systems/derivative/events/" + enumAsString + "/hooks/" + hookId.ToString("D"); var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/vnd.api+json", "application/json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } // authentication (oauth2_access_code) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // authentication (oauth2_application) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.DELETE, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("DeleteHook", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <dynamic>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null)); }
/// <summary> /// /// </summary> /// <remarks> /// Deletes the webhook with the given GUID for the given model derivative event. /// </remarks> /// <exception cref="Autodesk.Forge.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="eventType">The webhook event type to delete hook for.</param> /// <param name="hookId">The GUID of the hook to delete.</param> /// <returns>Task of webhooks</returns> public async System.Threading.Tasks.Task DeleteHookAsync(DerivativeWebhookEvent eventType, Guid hookId) { ApiResponse <dynamic> localVarResponse = await DeleteHookAsyncWithHttpInfo(eventType, hookId); }
/// <summary> /// Returns hooks for model derivate events. /// </summary> /// <exception cref="Autodesk.Forge.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="eventType">The webhook event type to get hooks for. </param> /// <param name="acceptEncoding">If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format. (optional)</param> /// <returns>Task of ApiResponse (webhooks)</returns> public async System.Threading.Tasks.Task <ApiResponse <dynamic> > GetHooksAsyncWithHttpInfo(DerivativeWebhookEvent eventType, string acceptEncoding = null) { var enumAsString = EventEnumToString(eventType); var localVarPath = "/webhooks/v1/systems/derivative/events/" + enumAsString + "/hooks"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/vnd.api+json", "application/json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); if (acceptEncoding != null) { localVarHeaderParams.Add("Accept-Encoding", Configuration.ApiClient.ParameterToString(acceptEncoding)); // header parameter } // authentication (oauth2_access_code) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // authentication (oauth2_application) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("GetHooks", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse </*Manifest*/ dynamic>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), /*(Manifest)*/ Configuration.ApiClient.Deserialize(localVarResponse, typeof(JsonApiCollection)))); }
/// <summary> /// Returns hooks for model derivate events. /// </summary> /// <exception cref="Autodesk.Forge.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="eventType">The webhook event type to get hooks for. </param> /// <param name="acceptEncoding">If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format. (optional)</param> /// <returns>Task of webhooks</returns> public async System.Threading.Tasks.Task <dynamic> GetHooksAsync(DerivativeWebhookEvent eventType, string acceptEncoding = null) { ApiResponse <dynamic> localVarResponse = await GetHooksAsyncWithHttpInfo(eventType, acceptEncoding); return(localVarResponse.Data); }
/// <summary> /// /// </summary> /// <remarks> /// Creates a webhook for the given modelderivative event. /// </remarks> /// <exception cref="Autodesk.Forge.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="eventType">The webhook event type to create hool for.</param> /// <param name="callbackUrl">The callback URL the hook will call when triggered.</param> /// <param name="workflow">The workflow ID of a group of jobs.</param> /// <returns>Task of ApiResponse</returns> public async System.Threading.Tasks.Task <dynamic> CreateHookAsyncWithHttpInfo(DerivativeWebhookEvent eventType, string callbackUrl, string workflow) { // verify the required parameter 'urn' is set if (callbackUrl == null) { throw new ApiException(400, "Missing required parameter 'callbackUrl' when calling DerivativeWebhooksApi->CreateHookAsync"); } // verify the required parameter 'workflow' is set if (workflow == null) { throw new ApiException(400, "Missing required parameter 'workflow' when calling DerivativeWebhooksApi->CreateHookAsync"); } var enumAsString = EventEnumToString(eventType); var localVarPath = "/webhooks/v1/systems/derivative/events/" + enumAsString + "/hooks"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/vnd.api+json", "application/json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); var postBodyObject = CreateWebhookPostObject(callbackUrl, workflow); localVarPostBody = Configuration.ApiClient.Serialize(postBodyObject); // authentication (oauth2_access_code) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // authentication (oauth2_application) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("CreateHook", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse </*Job*/ dynamic>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), /*(Job)*/ localVarResponse)); }
/// <summary> /// /// </summary> /// <remarks> /// Creates a webhook for the given modelderivative event. /// </remarks> /// <exception cref="Autodesk.Forge.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="eventType">The webhook event type to create hool for.</param> /// <param name="callbackUrl">The callback URL the hook will call when triggered.</param> /// <param name="workflow">The workflow ID of a group of jobs.</param> /// <returns>Task of</returns> public async System.Threading.Tasks.Task <dynamic> CreateHookAsync(DerivativeWebhookEvent eventType, string callbackUrl, string workflow) { ApiResponse <dynamic> localVarResponse = await CreateHookAsyncWithHttpInfo(eventType, callbackUrl, workflow); return(localVarResponse.Data); }