// This is an automatically generated code sample. 
// To make this code sample work in your Oracle Cloud tenancy, 
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and 
// boolean, number, and enum parameters with values not fitting your use case).

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.ApmsyntheticsService;
using Oci.Common;
using Oci.Common.Auth;

namespace Oci.Sdk.DotNet.Example.Apmsynthetics
{
    public class UpdateMonitorExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var updateMonitorDetails = new Oci.ApmsyntheticsService.Models.UpdateMonitorDetails
			{
				DisplayName = "EXAMPLE-displayName-Value",
				VantagePoints = new List<string>
				{
					"EXAMPLE--Value"
				},
				ScriptId = "ocid1.test.oc1..<unique_ID>EXAMPLE-scriptId-Value",
				Status = Oci.ApmsyntheticsService.Models.MonitorStatus.Invalid,
				RepeatIntervalInSeconds = 928,
				IsRunOnce = true,
				TimeoutInSeconds = 821,
				Target = "EXAMPLE-target-Value",
				ScriptParameters = new List<Oci.ApmsyntheticsService.Models.MonitorScriptParameter>
				{
					new Oci.ApmsyntheticsService.Models.MonitorScriptParameter
					{
						ParamName = "EXAMPLE-paramName-Value",
						ParamValue = "EXAMPLE-paramValue-Value"
					}
				},
				Configuration = new Oci.ApmsyntheticsService.Models.FtpMonitorConfiguration
				{
					FtpProtocol = Oci.ApmsyntheticsService.Models.FtpProtocol.Ftp,
					FtpRequestType = Oci.ApmsyntheticsService.Models.FtpRequestType.Download,
					IsActiveMode = false,
					FtpBasicAuthenticationDetails = new Oci.ApmsyntheticsService.Models.BasicAuthenticationDetails
					{
						Username = "EXAMPLE-username-Value",
						Password = new Oci.ApmsyntheticsService.Models.PasswordInText
						{
							Password = "EXAMPLE-password-Value"
						}
					},
					DownloadSizeLimitInBytes = 2086574,
					UploadFileSizeInBytes = 654257,
					NetworkConfiguration = new Oci.ApmsyntheticsService.Models.NetworkConfiguration
					{
						NumberOfHops = 60,
						ProbePerHop = 6,
						TransmissionRate = 49,
						Protocol = Oci.ApmsyntheticsService.Models.Protocol.Tcp,
						ProbeMode = Oci.ApmsyntheticsService.Models.ProbeMode.Sack
					},
					VerifyResponseCodes = new List<string>
					{
						"EXAMPLE--Value"
					},
					VerifyResponseContent = "EXAMPLE-verifyResponseContent-Value",
					IsFailureRetried = false,
					DnsConfiguration = new Oci.ApmsyntheticsService.Models.DnsConfiguration
					{
						IsOverrideDns = false,
						OverrideDnsIp = "EXAMPLE-overrideDnsIp-Value"
					}
				},
				AvailabilityConfiguration = new Oci.ApmsyntheticsService.Models.AvailabilityConfiguration
				{
					MaxAllowedFailuresPerInterval = 226,
					MinAllowedRunsPerInterval = 225
				},
				MaintenanceWindowSchedule = new Oci.ApmsyntheticsService.Models.MaintenanceWindowSchedule
				{
					TimeStarted = DateTime.Parse("05/21/2045 02:35:56"),
					TimeEnded = DateTime.Parse("01/20/2020 07:30:16")
				},
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_mCF2t", 
						"EXAMPLE_VALUE_hocQzXRKniX3rclPDhvB"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_01v7m", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_I6RzW", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				IsRunNow = true,
				SchedulingPolicy = Oci.ApmsyntheticsService.Models.SchedulingPolicy.All,
				BatchIntervalInSeconds = 176,
				IsIPv6 = true
			};
			var updateMonitorRequest = new Oci.ApmsyntheticsService.Requests.UpdateMonitorRequest
			{
				ApmDomainId = "ocid1.test.oc1..<unique_ID>EXAMPLE-apmDomainId-Value",
				MonitorId = "ocid1.test.oc1..<unique_ID>EXAMPLE-monitorId-Value",
				UpdateMonitorDetails = updateMonitorDetails,
				IfMatch = "EXAMPLE-ifMatch-Value",
				OpcRequestId = "BXWMA46AKRLCKO5BLQLC<unique_ID>"
			};

            // Create a default authentication provider that uses the DEFAULT
            // profile in the configuration file.
            // Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file. 
            var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
            try
            {
                // Create a service client and send the request.
				using (var client = new ApmSyntheticClient(provider, new ClientConfiguration()))
				{
					var response = await client.UpdateMonitor(updateMonitorRequest);
					// Retrieve value from the response.
					var id = response.Monitor.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"UpdateMonitor Failed with {e.Message}");
                throw e;
            }
        }

    }
}

Was this article helpful?