// 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 CreateMonitorExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createMonitorDetails = new Oci.ApmsyntheticsService.Models.CreateMonitorDetails
{
DisplayName = "EXAMPLE-displayName-Value",
MonitorType = Oci.ApmsyntheticsService.Models.MonitorTypes.Ftp,
VantagePoints = new List<string>
{
"EXAMPLE--Value"
},
ScriptId = "ocid1.test.oc1..<unique_ID>EXAMPLE-scriptId-Value",
Status = Oci.ApmsyntheticsService.Models.MonitorStatus.Disabled,
RepeatIntervalInSeconds = 514,
IsRunOnce = false,
TimeoutInSeconds = 185,
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.RestMonitorConfiguration
{
IsRedirectionEnabled = false,
IsCertificateValidationEnabled = false,
RequestMethod = Oci.ApmsyntheticsService.Models.RequestMethods.Get,
ReqAuthenticationScheme = Oci.ApmsyntheticsService.Models.RequestAuthenticationSchemes.None,
ReqAuthenticationDetails = new Oci.ApmsyntheticsService.Models.RequestAuthenticationDetails
{
OauthScheme = Oci.ApmsyntheticsService.Models.OAuthSchemes.Basic,
AuthUserName = "EXAMPLE-authUserName-Value",
AuthUserPassword = "EXAMPLE-authUserPassword-Value",
AuthToken = "EXAMPLE-authToken-Value",
AuthUrl = "EXAMPLE-authUrl-Value",
AuthHeaders = new List<Oci.ApmsyntheticsService.Models.Header>
{
new Oci.ApmsyntheticsService.Models.Header
{
HeaderName = "EXAMPLE-headerName-Value",
HeaderValue = "EXAMPLE-headerValue-Value"
}
},
AuthRequestMethod = Oci.ApmsyntheticsService.Models.RequestMethods.Post,
AuthRequestPostBody = "EXAMPLE-authRequestPostBody-Value"
},
ClientCertificateDetails = new Oci.ApmsyntheticsService.Models.ClientCertificateDetails
{
ClientCertificate = new Oci.ApmsyntheticsService.Models.ClientCertificate
{
FileName = "EXAMPLE-fileName-Value",
Content = "EXAMPLE-content-Value"
},
PrivateKey = new Oci.ApmsyntheticsService.Models.PrivateKey
{
FileName = "EXAMPLE-fileName-Value",
Content = "EXAMPLE-content-Value"
}
},
RequestHeaders = new List<Oci.ApmsyntheticsService.Models.Header>
{
new Oci.ApmsyntheticsService.Models.Header
{
HeaderName = "EXAMPLE-headerName-Value",
HeaderValue = "EXAMPLE-headerValue-Value"
}
},
RequestQueryParams = new List<Oci.ApmsyntheticsService.Models.RequestQueryParam>
{
new Oci.ApmsyntheticsService.Models.RequestQueryParam
{
ParamName = "EXAMPLE-paramName-Value",
ParamValue = "EXAMPLE-paramValue-Value"
}
},
RequestPostBody = "EXAMPLE-requestPostBody-Value",
VerifyResponseContent = "EXAMPLE-verifyResponseContent-Value",
VerifyResponseCodes = new List<string>
{
"EXAMPLE--Value"
},
NetworkConfiguration = new Oci.ApmsyntheticsService.Models.NetworkConfiguration
{
NumberOfHops = 240,
ProbePerHop = 3,
TransmissionRate = 87,
Protocol = Oci.ApmsyntheticsService.Models.Protocol.Icmp,
ProbeMode = Oci.ApmsyntheticsService.Models.ProbeMode.Sack
},
IsFailureRetried = true,
DnsConfiguration = new Oci.ApmsyntheticsService.Models.DnsConfiguration
{
IsOverrideDns = false,
OverrideDnsIp = "EXAMPLE-overrideDnsIp-Value"
}
},
AvailabilityConfiguration = new Oci.ApmsyntheticsService.Models.AvailabilityConfiguration
{
MaxAllowedFailuresPerInterval = 956,
MinAllowedRunsPerInterval = 227
},
MaintenanceWindowSchedule = new Oci.ApmsyntheticsService.Models.MaintenanceWindowSchedule
{
TimeStarted = DateTime.Parse("08/09/2010 18:51:14"),
TimeEnded = DateTime.Parse("04/27/2017 01:08:27")
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_DHYQ8",
"EXAMPLE_VALUE_RdDudRiSz0EDC46UABu2"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_FIMhw",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_c069f",
"EXAMPLE--Value"
}
}
}
},
IsRunNow = true,
SchedulingPolicy = Oci.ApmsyntheticsService.Models.SchedulingPolicy.BatchedRoundRobin,
BatchIntervalInSeconds = 293,
IsIPv6 = true
};
var createMonitorRequest = new Oci.ApmsyntheticsService.Requests.CreateMonitorRequest
{
ApmDomainId = "ocid1.test.oc1..<unique_ID>EXAMPLE-apmDomainId-Value",
CreateMonitorDetails = createMonitorDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "KDJAOCGL1JHZNTQEL9YH<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.CreateMonitor(createMonitorRequest);
// Retrieve value from the response.
var id = response.Monitor.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateMonitor Failed with {e.Message}");
throw e;
}
}
}
}