/** 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).
*/

import com.oracle.bmc.ConfigFileReader;
import com.oracle.bmc.auth.AuthenticationDetailsProvider;
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider;
import com.oracle.bmc.stackmonitoring.StackMonitoringClient;
import com.oracle.bmc.stackmonitoring.model.*;
import com.oracle.bmc.stackmonitoring.requests.*;
import com.oracle.bmc.stackmonitoring.responses.*;
import java.math.BigDecimal;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Date;
import java.util.UUID;
import java.util.Arrays;


public class SearchMonitoredResourcesExample {
    public static void main(String[] args) throws Exception {

        /**
         * 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.
         */
        final ConfigFileReader.ConfigFile configFile = ConfigFileReader.parseDefault();
        final AuthenticationDetailsProvider provider = new ConfigFileAuthenticationDetailsProvider(configFile);

        /* Create a service client */
        StackMonitoringClient client = StackMonitoringClient.builder().build(provider);

        /* Create a request and dependent object(s). */
	SearchMonitoredResourcesDetails searchMonitoredResourcesDetails = SearchMonitoredResourcesDetails.builder()
		.compartmentId("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value")
		.compartmentIds(new ArrayList<>(Arrays.asList("EXAMPLE--Value")))
		.lifecycleStates(new ArrayList<>(Arrays.asList(ResourceLifecycleState.Creating,ResourceLifecycleState.Updating,ResourceLifecycleState.Active,ResourceLifecycleState.Deleting,ResourceLifecycleState.Deleted,ResourceLifecycleState.Failed)))
		.sourceType(SourceType.Collectd)
		.resourceCategory(ResourceCategory.Middleware)
		.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(ResourceLifecycleState.Updating)
		.license(LicenseType.StandardEdition)
		.timeCreatedGreaterThanOrEqualTo(new Date("Sat Aug 01 23:20:24 UTC 2048"))
		.timeCreatedLessThan(new Date("Sun Feb 21 23:20:21 UTC 2049"))
		.timeUpdatedGreaterThanOrEqualTo(new Date("Sat Mar 29 20:33:30 UTC 2042"))
		.timeUpdatedLessThan(new Date("Tue Mar 26 18:21:54 UTC 2024"))
		.resourceTimeZone("EXAMPLE-resourceTimeZone-Value")
		.sortOrder(SortOrder.Asc)
		.sortBy(SearchMonitoredResourcesDetails.SortBy.TimeCreated)
		.propertyEquals(new HashMap<java.lang.String, java.lang.String>() {
				{
					put("EXAMPLE_KEY_pHfdE","EXAMPLE_VALUE_uB0VX4p7D63B9tmlaf3S");
				}
 			}).build();

	SearchMonitoredResourcesRequest searchMonitoredResourcesRequest = SearchMonitoredResourcesRequest.builder()
		.searchMonitoredResourcesDetails(searchMonitoredResourcesDetails)
		.limit(774)
		.page("EXAMPLE-page-Value")
		.fields(new ArrayList<>(Arrays.asList("EXAMPLE--Value")))
		.excludeFields(new ArrayList<>(Arrays.asList("EXAMPLE--Value")))
		.opcRequestId("QUM3XVZ7XOHVE62XTQLD<unique_ID>")
		.opcRetryToken("EXAMPLE-opcRetryToken-Value")
		.ifMatch("EXAMPLE-ifMatch-Value").build();

        /* Send request to the Client */
        SearchMonitoredResourcesResponse response = client.searchMonitoredResources(searchMonitoredResourcesRequest);
    }

    
}

Was this article helpful?