internal virtual CreateWebhookResponse CreateWebhook(CreateWebhookRequest request) { var marshaller = new CreateWebhookRequestMarshaller(); var unmarshaller = CreateWebhookResponseUnmarshaller.Instance; return(Invoke <CreateWebhookRequest, CreateWebhookResponse>(request, marshaller, unmarshaller)); }
public void CreateWebhookResourceNames() { moq::Mock <Webhooks.WebhooksClient> mockGrpcClient = new moq::Mock <Webhooks.WebhooksClient>(moq::MockBehavior.Strict); CreateWebhookRequest request = new CreateWebhookRequest { ParentAsAgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"), Webhook = new Webhook(), }; Webhook expectedResponse = new Webhook { WebhookName = WebhookName.FromProjectLocationAgentWebhook("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]"), DisplayName = "display_name137f65c2", GenericWebService = new Webhook.Types.GenericWebService(), Disabled = false, Timeout = new wkt::Duration(), ServiceDirectory = new Webhook.Types.ServiceDirectoryConfig(), }; mockGrpcClient.Setup(x => x.CreateWebhook(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); WebhooksClient client = new WebhooksClientImpl(mockGrpcClient.Object, null); Webhook response = client.CreateWebhook(request.ParentAsAgentName, request.Webhook); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task CreateWebhookResourceNamesAsync() { moq::Mock <Webhooks.WebhooksClient> mockGrpcClient = new moq::Mock <Webhooks.WebhooksClient>(moq::MockBehavior.Strict); CreateWebhookRequest request = new CreateWebhookRequest { ParentAsAgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"), Webhook = new Webhook(), }; Webhook expectedResponse = new Webhook { WebhookName = WebhookName.FromProjectLocationAgentWebhook("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]"), DisplayName = "display_name137f65c2", GenericWebService = new Webhook.Types.GenericWebService(), Disabled = false, Timeout = new wkt::Duration(), }; mockGrpcClient.Setup(x => x.CreateWebhookAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Webhook>(stt::Task.FromResult(expectedResponse), null, null, null, null)); WebhooksClient client = new WebhooksClientImpl(mockGrpcClient.Object, null); Webhook responseCallSettings = await client.CreateWebhookAsync(request.ParentAsAgentName, request.Webhook, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Webhook responseCancellationToken = await client.CreateWebhookAsync(request.ParentAsAgentName, request.Webhook, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary> /// Initiates the asynchronous execution of the CreateWebhook operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateWebhook operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/codebuild-2016-10-06/CreateWebhook">REST API Reference for CreateWebhook Operation</seealso> public virtual Task <CreateWebhookResponse> CreateWebhookAsync(CreateWebhookRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateWebhookRequestMarshaller(); var unmarshaller = CreateWebhookResponseUnmarshaller.Instance; return(InvokeAsync <CreateWebhookRequest, CreateWebhookResponse>(request, marshaller, unmarshaller, cancellationToken)); }
internal void TestCreateWebhook(CreateWebhookRequest request, string httpResponse, Webhook response) { this.Given(x => GivenACreateWebhookRequest(request)) .When(x => WhenCreatingAWebhook(httpResponse)) .Then(x => ThenItShouldCallTheHttpClientPost()) .And(x => ThenItShouldReturnTheWebhook(response)) .BDDfy(); }
public async Task <Webhook> CreateWebhookAsync(CreateWebhookRequest request) { var json = JsonConvert.SerializeObject(request, _defaultJsonSerializerSettings); var result = await _httpClientProxy.PostAsync("/v1/webhooks", json).ConfigureAwait(false); var webhook = JsonConvert.DeserializeObject <Webhook>(result, _defaultJsonSerializerSettings); return(webhook); }
/// <summary> /// Initiates the asynchronous execution of the CreateWebhook operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateWebhook operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/codebuild-2016-10-06/CreateWebhook">REST API Reference for CreateWebhook Operation</seealso> public virtual Task <CreateWebhookResponse> CreateWebhookAsync(CreateWebhookRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = CreateWebhookRequestMarshaller.Instance; options.ResponseUnmarshaller = CreateWebhookResponseUnmarshaller.Instance; return(InvokeAsync <CreateWebhookResponse>(request, options, cancellationToken)); }
internal virtual CreateWebhookResponse CreateWebhook(CreateWebhookRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = CreateWebhookRequestMarshaller.Instance; options.ResponseUnmarshaller = CreateWebhookResponseUnmarshaller.Instance; return(Invoke <CreateWebhookResponse>(request, options)); }
public async Task <Webhook> CreateWebhookAsync(CreateWebhookRequest createWebhookRequest) { ValidateModel(createWebhookRequest); var response = await PostAsJsonAsync("/webhooks", JsonConvert.SerializeObject(createWebhookRequest)); return(JsonConvert.DeserializeObject <WebhookResponse>( await response.Content.ReadAsStringAsync()).Webhook); }
/// <summary> /// Create a new webhook /// </summary> /// /// <param name="request">update fields value</param> /// <param name="siteId"> Unique identifier for the site</param> /// <returns>The <see cref="Order"/>.</returns> public virtual async Task <WebhookModel> CreateWebhook(string siteId, CreateWebhookRequest request) { var req = PrepareRequest($"sites/{siteId}/webhooks"); HttpContent content = null; if (request != null) { var body = request.ToDictionary(); content = new JsonContent(body); } return(await ExecuteRequestAsync <WebhookModel>(req, HttpMethod.Post, content)); }
/// <summary>Snippet for CreateWebhook</summary> public void CreateWebhookRequestObject() { // Snippet: CreateWebhook(CreateWebhookRequest, CallSettings) // Create client WebhooksClient webhooksClient = WebhooksClient.Create(); // Initialize request argument(s) CreateWebhookRequest request = new CreateWebhookRequest { ParentAsAgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"), Webhook = new Webhook(), }; // Make the request Webhook response = webhooksClient.CreateWebhook(request); // End snippet }
/// <summary>Snippet for CreateWebhookAsync</summary> public async Task CreateWebhookRequestObjectAsync() { // Snippet: CreateWebhookAsync(CreateWebhookRequest, CallSettings) // Additional: CreateWebhookAsync(CreateWebhookRequest, CancellationToken) // Create client WebhooksClient webhooksClient = await WebhooksClient.CreateAsync(); // Initialize request argument(s) CreateWebhookRequest request = new CreateWebhookRequest { ParentAsAgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"), Webhook = new Webhook(), }; // Make the request Webhook response = await webhooksClient.CreateWebhookAsync(request); // End snippet }
public async void TestCreate() { String accessToken = this.RandomString(); String url = this.RandomString(); List <String> triggerIds = new List <String> { this.RandomString() }; CreateWebhookRequest req = new CreateWebhookRequest(); req.TriggerIds = triggerIds; req.Url = url; MockAPI <Webhooks> mock = this.MockFor <Webhooks>( HttpMethod.Post, "/api/v1/webhooks.create", m => m.WithContent(req.ToString()).Respond("application/json", "{\"webhook\":{\"webhookId\":\"" + this.RandomString() + "\"}}") ); APIResponse <WebhookResponseBody> res = await mock.Instance.Create(accessToken, url, triggerIds, null); mock.Handler.VerifyNoOutstandingExpectation(); Assert.NotNull(res.Body.Webhook); }
private void GivenACreateWebhookRequest(CreateWebhookRequest createWebhookRequest) { _createWebhookRequest = createWebhookRequest; }
/// <summary> /// Create new webhook /// </summary> /// <param name="projectId">The ID, path or <see cref="Project"/> of the project.</param> /// <param name="request">Create hook request.</param> /// <returns>newly created hook</returns> public async Task <Webhook> CreateAsync(ProjectId projectId, CreateWebhookRequest request) => await _httpFacade.Post <Webhook>($"projects/{projectId}/hooks", request);
/// <summary> /// Update new webhook /// </summary> /// <param name="projectId">The ID, path or <see cref="Project"/> of the project.</param> /// <param name="hookId">The hook ID, you want to update.</param> /// <param name="request">Create hook request.</param> /// <returns>newly created hook</returns> public async Task <Webhook> UpdateAsync(ProjectId projectId, long hookId, CreateWebhookRequest request) => await _httpFacade.Put <Webhook>($"projects/{projectId}/hooks/{hookId}", request);