/// <summary>Snippet for GetWebhook</summary>
 public void GetWebhookResourceNames()
 {
     // Snippet: GetWebhook(WebhookName, CallSettings)
     // Create client
     WebhooksClient webhooksClient = WebhooksClient.Create();
     // Initialize request argument(s)
     WebhookName name = WebhookName.FromProjectLocationAgentWebhook("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]");
     // Make the request
     Webhook response = webhooksClient.GetWebhook(name);
     // End snippet
 }
 /// <summary>Snippet for GetWebhook</summary>
 public void GetWebhook()
 {
     // Snippet: GetWebhook(string, CallSettings)
     // Create client
     WebhooksClient webhooksClient = WebhooksClient.Create();
     // Initialize request argument(s)
     string name = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/webhooks/[WEBHOOK]";
     // Make the request
     Webhook response = webhooksClient.GetWebhook(name);
     // End snippet
 }
 /// <summary>Snippet for UpdateWebhook</summary>
 public void UpdateWebhook()
 {
     // Snippet: UpdateWebhook(Webhook, FieldMask, CallSettings)
     // Create client
     WebhooksClient webhooksClient = WebhooksClient.Create();
     // Initialize request argument(s)
     Webhook   webhook    = new Webhook();
     FieldMask updateMask = new FieldMask();
     // Make the request
     Webhook response = webhooksClient.UpdateWebhook(webhook, updateMask);
     // End snippet
 }
 /// <summary>Snippet for CreateWebhook</summary>
 public void CreateWebhookResourceNames()
 {
     // Snippet: CreateWebhook(AgentName, Webhook, CallSettings)
     // Create client
     WebhooksClient webhooksClient = WebhooksClient.Create();
     // Initialize request argument(s)
     AgentName parent  = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]");
     Webhook   webhook = new Webhook();
     // Make the request
     Webhook response = webhooksClient.CreateWebhook(parent, webhook);
     // End snippet
 }
 /// <summary>Snippet for CreateWebhook</summary>
 public void CreateWebhook()
 {
     // Snippet: CreateWebhook(string, Webhook, CallSettings)
     // Create client
     WebhooksClient webhooksClient = WebhooksClient.Create();
     // Initialize request argument(s)
     string  parent  = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]";
     Webhook webhook = new Webhook();
     // Make the request
     Webhook response = webhooksClient.CreateWebhook(parent, webhook);
     // End snippet
 }
 /// <summary>Snippet for GetWebhook</summary>
 public void GetWebhookRequestObject()
 {
     // Snippet: GetWebhook(GetWebhookRequest, CallSettings)
     // Create client
     WebhooksClient webhooksClient = WebhooksClient.Create();
     // Initialize request argument(s)
     GetWebhookRequest request = new GetWebhookRequest
     {
         WebhookName = WebhookName.FromProjectLocationAgentWebhook("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]"),
     };
     // Make the request
     Webhook response = webhooksClient.GetWebhook(request);
     // End snippet
 }
            public void PostsToTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new WebhooksClient(connection);

                var newWebhook = new NewWebhook("https://test.com", "*", "*");

                client.Create(newWebhook);

                connection.Received().Post <Webhook>(Arg.Is <Uri>(u => u.ToString() == "webhooks"),
                                                     Arg.Is <NewWebhook>(df => df.EventAction == "*" &&
                                                                         df.EventObject == "*" &&
                                                                         df.SubscriptionUrl == "https://test.com"));
            }
 /// <summary>Snippet for UpdateWebhook</summary>
 public void UpdateWebhookRequestObject()
 {
     // Snippet: UpdateWebhook(UpdateWebhookRequest, CallSettings)
     // Create client
     WebhooksClient webhooksClient = WebhooksClient.Create();
     // Initialize request argument(s)
     UpdateWebhookRequest request = new UpdateWebhookRequest
     {
         Webhook    = new Webhook(),
         UpdateMask = new FieldMask(),
     };
     // Make the request
     Webhook response = webhooksClient.UpdateWebhook(request);
     // End snippet
 }
 /// <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 DeleteWebhook</summary>
        public void DeleteWebhookRequestObject()
        {
            // Snippet: DeleteWebhook(DeleteWebhookRequest, CallSettings)
            // Create client
            WebhooksClient webhooksClient = WebhooksClient.Create();
            // Initialize request argument(s)
            DeleteWebhookRequest request = new DeleteWebhookRequest
            {
                WebhookName = WebhookName.FromProjectLocationAgentWebhook("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]"),
                Force       = false,
            };

            // Make the request
            webhooksClient.DeleteWebhook(request);
            // End snippet
        }
        /// <summary>Snippet for ListWebhooks</summary>
        public void ListWebhooksRequestObject()
        {
            // Snippet: ListWebhooks(ListWebhooksRequest, CallSettings)
            // Create client
            WebhooksClient webhooksClient = WebhooksClient.Create();
            // Initialize request argument(s)
            ListWebhooksRequest request = new ListWebhooksRequest
            {
                ParentAsAgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"),
            };
            // Make the request
            PagedEnumerable <ListWebhooksResponse, Webhook> response = webhooksClient.ListWebhooks(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (Webhook item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListWebhooksResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Webhook item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int            pageSize   = 10;
            Page <Webhook> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Webhook item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
            public async Task EnsuresNonNullArguments()
            {
                var client = new WebhooksClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null));
            }