public void Dispose() { NotificationChannelClient.DeleteNotificationChannel( NotificationChannelName.Parse(Channel.Name), true); AlertPolicyClient.DeleteAlertPolicy( AlertPolicyName.Parse(Alert.Name)); }
public void TestReplaceChannels() { var result = _alert.Run("replace-channels", "-p", _fixture.ProjectId, "-a", AlertPolicyName.Parse(_fixture.Alert.Name).AlertPolicyId, "-c", NotificationChannelName.Parse(_fixture.Channel.Name) .NotificationChannelId); Assert.Equal(0, result.ExitCode); }
/// <summary>Snippet for GetAlertPolicy</summary> public void GetAlertPolicyResourceNames1() { // Snippet: GetAlertPolicy(AlertPolicyName, CallSettings) // Create client AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.Create(); // Initialize request argument(s) AlertPolicyName name = AlertPolicyName.FromProjectAlertPolicy("[PROJECT]", "[ALERT_POLICY]"); // Make the request AlertPolicy response = alertPolicyServiceClient.GetAlertPolicy(name); // End snippet }
/// <summary>Snippet for DeleteAlertPolicy</summary> public void DeleteAlertPolicy() { // Snippet: DeleteAlertPolicy(AlertPolicyName,CallSettings) // Create client AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.Create(); // Initialize request argument(s) AlertPolicyName name = new AlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); // Make the request alertPolicyServiceClient.DeleteAlertPolicy(name); // End snippet }
/// <summary>Snippet for DeleteAlertPolicyAsync</summary> public async Task DeleteAlertPolicyResourceNames1Async() { // Snippet: DeleteAlertPolicyAsync(AlertPolicyName, CallSettings) // Additional: DeleteAlertPolicyAsync(AlertPolicyName, CancellationToken) // Create client AlertPolicyServiceClient alertPolicyServiceClient = await AlertPolicyServiceClient.CreateAsync(); // Initialize request argument(s) AlertPolicyName name = AlertPolicyName.FromProjectAlertPolicy("[PROJECT]", "[ALERT_POLICY]"); // Make the request await alertPolicyServiceClient.DeleteAlertPolicyAsync(name); // End snippet }
/// <summary>Snippet for GetAlertPolicy</summary> public void GetAlertPolicyRequestObject() { // Snippet: GetAlertPolicy(GetAlertPolicyRequest, CallSettings) // Create client AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.Create(); // Initialize request argument(s) GetAlertPolicyRequest request = new GetAlertPolicyRequest { AlertPolicyName = AlertPolicyName.FromProjectAlertPolicy("[PROJECT]", "[ALERT_POLICY]"), }; // Make the request AlertPolicy response = alertPolicyServiceClient.GetAlertPolicy(request); // End snippet }
/// <summary>Snippet for GetAlertPolicyAsync</summary> public async Task GetAlertPolicyAsync() { // Snippet: GetAlertPolicyAsync(AlertPolicyName,CallSettings) // Additional: GetAlertPolicyAsync(AlertPolicyName,CancellationToken) // Create client AlertPolicyServiceClient alertPolicyServiceClient = await AlertPolicyServiceClient.CreateAsync(); // Initialize request argument(s) AlertPolicyName name = new AlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); // Make the request AlertPolicy response = await alertPolicyServiceClient.GetAlertPolicyAsync(name); // End snippet }
/// <summary>Snippet for GetAlertPolicyAsync</summary> public async Task GetAlertPolicyRequestObjectAsync() { // Snippet: GetAlertPolicyAsync(GetAlertPolicyRequest, CallSettings) // Additional: GetAlertPolicyAsync(GetAlertPolicyRequest, CancellationToken) // Create client AlertPolicyServiceClient alertPolicyServiceClient = await AlertPolicyServiceClient.CreateAsync(); // Initialize request argument(s) GetAlertPolicyRequest request = new GetAlertPolicyRequest { AlertPolicyName = AlertPolicyName.FromProjectAlertPolicy("[PROJECT]", "[ALERT_POLICY]"), }; // Make the request AlertPolicy response = await alertPolicyServiceClient.GetAlertPolicyAsync(request); // End snippet }
// [END monitoring_alert_enable_policies] // [END monitoring_alert_disable_policies] static void DeleteAlertPolicy(string policyNameString) { var client = AlertPolicyServiceClient.Create(); AlertPolicyName policyName; if (!AlertPolicyName.TryParse(policyNameString, out policyName)) { string message = string.Format( @"{0} is not a valid alert policy name. Policy names look like this: {1}.", policyNameString, new AlertPolicyName("project-id", "alert-policy-id")); throw new Exception(message); } client.DeleteAlertPolicy(policyName); Console.WriteLine($"Deleted {policyName}."); }
public async Task DeleteAlertPolicyAsync() { Mock <AlertPolicyService.AlertPolicyServiceClient> mockGrpcClient = new Mock <AlertPolicyService.AlertPolicyServiceClient>(MockBehavior.Strict); DeleteAlertPolicyRequest expectedRequest = new DeleteAlertPolicyRequest { AlertPolicyName = new AlertPolicyName("[PROJECT]", "[ALERT_POLICY]"), }; Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteAlertPolicyAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Empty>(Task.FromResult(expectedResponse), null, null, null, null)); AlertPolicyServiceClient client = new AlertPolicyServiceClientImpl(mockGrpcClient.Object, null); AlertPolicyName name = new AlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); await client.DeleteAlertPolicyAsync(name); mockGrpcClient.VerifyAll(); }
public void DeleteAlertPolicy() { Mock <AlertPolicyService.AlertPolicyServiceClient> mockGrpcClient = new Mock <AlertPolicyService.AlertPolicyServiceClient>(MockBehavior.Strict); DeleteAlertPolicyRequest expectedRequest = new DeleteAlertPolicyRequest { AlertPolicyName = new AlertPolicyName("[PROJECT]", "[ALERT_POLICY]"), }; Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteAlertPolicy(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); AlertPolicyServiceClient client = new AlertPolicyServiceClientImpl(mockGrpcClient.Object, null); AlertPolicyName name = new AlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); client.DeleteAlertPolicy(name); mockGrpcClient.VerifyAll(); }
public async Task GetAlertPolicyAsync() { Mock <AlertPolicyService.AlertPolicyServiceClient> mockGrpcClient = new Mock <AlertPolicyService.AlertPolicyServiceClient>(MockBehavior.Strict); GetAlertPolicyRequest expectedRequest = new GetAlertPolicyRequest { AlertPolicyName = new AlertPolicyName("[PROJECT]", "[ALERT_POLICY]"), }; AlertPolicy expectedResponse = new AlertPolicy { Name = "name2-1052831874", DisplayName = "displayName1615086568", }; mockGrpcClient.Setup(x => x.GetAlertPolicyAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <AlertPolicy>(Task.FromResult(expectedResponse), null, null, null, null)); AlertPolicyServiceClient client = new AlertPolicyServiceClientImpl(mockGrpcClient.Object, null); AlertPolicyName name = new AlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); AlertPolicy response = await client.GetAlertPolicyAsync(name); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetAlertPolicy() { Mock <AlertPolicyService.AlertPolicyServiceClient> mockGrpcClient = new Mock <AlertPolicyService.AlertPolicyServiceClient>(MockBehavior.Strict); GetAlertPolicyRequest expectedRequest = new GetAlertPolicyRequest { AlertPolicyName = new AlertPolicyName("[PROJECT]", "[ALERT_POLICY]"), }; AlertPolicy expectedResponse = new AlertPolicy { Name = "name2-1052831874", DisplayName = "displayName1615086568", }; mockGrpcClient.Setup(x => x.GetAlertPolicy(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); AlertPolicyServiceClient client = new AlertPolicyServiceClientImpl(mockGrpcClient.Object, null); AlertPolicyName name = new AlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); AlertPolicy response = client.GetAlertPolicy(name); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }