// 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 SearchMonitoredResourcesExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var searchMonitoredResourcesDetails = new Oci.StackmonitoringService.Models.SearchMonitoredResourcesDetails
{
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
CompartmentIds = new List<string>
{
"EXAMPLE--Value"
},
LifecycleStates = new List<Oci.StackmonitoringService.Models.ResourceLifecycleState>
{
Oci.StackmonitoringService.Models.ResourceLifecycleState.Creating,
Oci.StackmonitoringService.Models.ResourceLifecycleState.Updating,
Oci.StackmonitoringService.Models.ResourceLifecycleState.Active,
Oci.StackmonitoringService.Models.ResourceLifecycleState.Inactive,
Oci.StackmonitoringService.Models.ResourceLifecycleState.Deleting,
Oci.StackmonitoringService.Models.ResourceLifecycleState.Deleted,
Oci.StackmonitoringService.Models.ResourceLifecycleState.Failed
},
SourceType = Oci.StackmonitoringService.Models.SourceType.Prometheus,
ResourceCategory = Oci.StackmonitoringService.Models.ResourceCategory.Database,
Name = "EXAMPLE-name-Value",
NameContains = "EXAMPLE-nameContains-Value",
Type = "EXAMPLE-type-Value",
HostName = "EXAMPLE-hostName-Value",
ExternalId = "ocid1.test.oc1..<unique_ID>EXAMPLE-externalId-Value",
HostNameContains = "EXAMPLE-hostNameContains-Value",
ManagementAgentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-managementAgentId-Value",
LifecycleState = Oci.StackmonitoringService.Models.ResourceLifecycleState.Active,
License = Oci.StackmonitoringService.Models.LicenseType.EnterpriseEditionForGpuInfrastructure,
TimeCreatedGreaterThanOrEqualTo = DateTime.Parse("11/20/2048 13:00:00"),
TimeCreatedLessThan = DateTime.Parse("12/16/2015 06:58:12"),
TimeUpdatedGreaterThanOrEqualTo = DateTime.Parse("03/13/2045 03:49:51"),
TimeUpdatedLessThan = DateTime.Parse("07/29/2009 20:15:32"),
ResourceTimeZone = "EXAMPLE-resourceTimeZone-Value",
SortOrder = Oci.StackmonitoringService.Models.SortOrder.Asc,
SortBy = Oci.StackmonitoringService.Models.SearchMonitoredResourcesDetails.SortByEnum.ResourceName,
PropertyEquals = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_mES7T",
"EXAMPLE_VALUE_8dpxwjhMN6fGkYs5qOub"
}
}
};
var searchMonitoredResourcesRequest = new Oci.StackmonitoringService.Requests.SearchMonitoredResourcesRequest
{
SearchMonitoredResourcesDetails = searchMonitoredResourcesDetails,
Limit = 539,
Page = "EXAMPLE-page-Value",
Fields = new List<string>
{
"EXAMPLE--Value"
},
ExcludeFields = new List<string>
{
"EXAMPLE--Value"
},
OpcRequestId = "XVCHFVFXJUFR4X0XZDRO<unique_ID>",
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
IfMatch = "EXAMPLE-ifMatch-Value"
};
// 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.SearchMonitoredResources(searchMonitoredResourcesRequest);
// Retrieve value from the response.
var hasValueValue = response.OpcTotalItems.HasValue;
}
}
catch (Exception e)
{
Console.WriteLine($"SearchMonitoredResources Failed with {e.Message}");
throw e;
}
}
}
}