/** 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.monitoring.MonitoringClient;
import com.oracle.bmc.monitoring.model.*;
import com.oracle.bmc.monitoring.requests.*;
import com.oracle.bmc.monitoring.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 CreateAlarmSuppressionExample {
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 */
MonitoringClient client = MonitoringClient.builder().build(provider);
/* Create a request and dependent object(s). */
CreateAlarmSuppressionDetails createAlarmSuppressionDetails = CreateAlarmSuppressionDetails.builder()
.alarmSuppressionTarget(AlarmSuppressionCompartmentTarget.builder()
.compartmentId("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value")
.compartmentIdInSubtree(false).build())
.level(AlarmSuppression.Level.Dimension)
.displayName("EXAMPLE-displayName-Value")
.description("EXAMPLE-description-Value")
.dimensions(new HashMap<java.lang.String, java.lang.String>() {
{
put("EXAMPLE_KEY_eKQJj","EXAMPLE_VALUE_KP3mchtDERhXOJJvYfat");
}
})
.timeSuppressFrom(new Date("Fri Dec 20 09:56:17 UTC 2030"))
.timeSuppressUntil(new Date("Thu May 10 05:39:57 UTC 2001"))
.freeformTags(new HashMap<java.lang.String, java.lang.String>() {
{
put("EXAMPLE_KEY_eF6rY","EXAMPLE_VALUE_Dv223RVVdoKAybOffrko");
}
})
.definedTags(new HashMap<java.lang.String, java.util.Map<java.lang.String, java.lang.Object>>() {
{
put("EXAMPLE_KEY_vtINv",new HashMap<java.lang.String, java.lang.Object>() {
{
put("EXAMPLE_KEY_BsQYV","EXAMPLE--Value");
}
});
}
})
.suppressionConditions(new ArrayList<>(Arrays.asList(Recurrence.builder()
.suppressionRecurrence("EXAMPLE-suppressionRecurrence-Value")
.suppressionDuration("EXAMPLE-suppressionDuration-Value").build()))).build();
CreateAlarmSuppressionRequest createAlarmSuppressionRequest = CreateAlarmSuppressionRequest.builder()
.createAlarmSuppressionDetails(createAlarmSuppressionDetails)
.opcRequestId("UQNSDGPAZ6TIOEATBHUC<unique_ID>")
.opcRetryToken("EXAMPLE-opcRetryToken-Value").build();
/* Send request to the Client */
CreateAlarmSuppressionResponse response = client.createAlarmSuppression(createAlarmSuppressionRequest);
}
}