// 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.StackmonitoringService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Stackmonitoring
{
public class UpdateMonitoredResourceExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var updateMonitoredResourceDetails = new Oci.StackmonitoringService.Models.UpdateMonitoredResourceDetails
{
DisplayName = "EXAMPLE-displayName-Value",
HostName = "EXAMPLE-hostName-Value",
ResourceTimeZone = "EXAMPLE-resourceTimeZone-Value",
Properties = new List<Oci.StackmonitoringService.Models.MonitoredResourceProperty>
{
new Oci.StackmonitoringService.Models.MonitoredResourceProperty
{
Name = "EXAMPLE-name-Value",
Value = "EXAMPLE-value-Value"
}
},
DatabaseConnectionDetails = new Oci.StackmonitoringService.Models.ConnectionDetails
{
Protocol = Oci.StackmonitoringService.Models.ConnectionDetails.ProtocolEnum.Tcp,
Port = 41825,
ConnectorId = "ocid1.test.oc1..<unique_ID>EXAMPLE-connectorId-Value",
ServiceName = "EXAMPLE-serviceName-Value",
DbUniqueName = "EXAMPLE-dbUniqueName-Value",
DbId = "ocid1.test.oc1..<unique_ID>EXAMPLE-dbId-Value",
SslSecretId = "ocid1.test.oc1..<unique_ID>EXAMPLE-sslSecretId-Value"
},
Credentials = new Oci.StackmonitoringService.Models.PreExistingCredentials
{
Source = "EXAMPLE-source-Value",
Name = "EXAMPLE-name-Value",
Type = "EXAMPLE-type-Value",
Description = "EXAMPLE-description-Value"
},
Aliases = new Oci.StackmonitoringService.Models.MonitoredResourceAliasCredential
{
Source = "EXAMPLE-source-Value",
Name = "EXAMPLE-name-Value",
Credential = new Oci.StackmonitoringService.Models.MonitoredResourceAliasSourceCredential
{
Source = "EXAMPLE-source-Value",
Name = "EXAMPLE-name-Value",
Service = "EXAMPLE-service-Value"
}
},
AdditionalCredentials = new List<Oci.StackmonitoringService.Models.MonitoredResourceCredential>
{
new Oci.StackmonitoringService.Models.PreExistingCredentials
{
Source = "EXAMPLE-source-Value",
Name = "EXAMPLE-name-Value",
Type = "EXAMPLE-type-Value",
Description = "EXAMPLE-description-Value"
}
},
AdditionalAliases = new List<Oci.StackmonitoringService.Models.MonitoredResourceAliasCredential>
{
new Oci.StackmonitoringService.Models.MonitoredResourceAliasCredential
{
Source = "EXAMPLE-source-Value",
Name = "EXAMPLE-name-Value",
Credential = new Oci.StackmonitoringService.Models.MonitoredResourceAliasSourceCredential
{
Source = "EXAMPLE-source-Value",
Name = "EXAMPLE-name-Value",
Service = "EXAMPLE-service-Value"
}
}
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_cXAFd",
"EXAMPLE_VALUE_5RgYS85KzSC8uQdaVvZj"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_K1Djz",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_wGTpo",
"EXAMPLE--Value"
}
}
}
}
};
var updateMonitoredResourceRequest = new Oci.StackmonitoringService.Requests.UpdateMonitoredResourceRequest
{
MonitoredResourceId = "ocid1.test.oc1..<unique_ID>EXAMPLE-monitoredResourceId-Value",
UpdateMonitoredResourceDetails = updateMonitoredResourceDetails,
IfMatch = "EXAMPLE-ifMatch-Value",
OpcRequestId = "DM6TBSLWXOVAWPJLMIFP<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 StackMonitoringClient(provider, new ClientConfiguration()))
{
var response = await client.UpdateMonitoredResource(updateMonitoredResourceRequest);
// Retrieve value from the response.
var versionValue = response.httpResponseMessage.Version;
}
}
catch (Exception e)
{
Console.WriteLine($"UpdateMonitoredResource Failed with {e.Message}");
throw e;
}
}
}
}