# 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).

from datetime import datetime
import oci

# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()


# Initialize service client with default config file
resource_scheduler_client = oci.resource_scheduler.ScheduleClient(config)


# Send the request to service, some parameters are not required, see API
# doc for more info
create_schedule_response = resource_scheduler_client.create_schedule(
    create_schedule_details=oci.resource_scheduler.models.CreateScheduleDetails(
        compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
        action="START_RESOURCE",
        recurrence_details="EXAMPLE-recurrenceDetails-Value",
        recurrence_type="ICAL",
        display_name="EXAMPLE-displayName-Value",
        description="EXAMPLE-description-Value",
        resource_filters=[
            oci.resource_scheduler.models.CompartmentIdResourceFilter(
                attribute="COMPARTMENT_ID",
                value="EXAMPLE-value-Value",
                should_include_child_compartments=True)],
        resources=[
            oci.resource_scheduler.models.Resource(
                id="ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
                metadata={
                    'EXAMPLE_KEY_90yg5': 'EXAMPLE_VALUE_BD5OPDaiNCsUM9yRoF6E'})],
        time_starts=datetime.strptime(
            "2038-06-14T15:27:00.933Z",
            "%Y-%m-%dT%H:%M:%S.%fZ"),
        time_ends=datetime.strptime(
            "2019-01-07T04:15:54.326Z",
            "%Y-%m-%dT%H:%M:%S.%fZ"),
        freeform_tags={
            'EXAMPLE_KEY_MOakY': 'EXAMPLE_VALUE_xXktR5Jp7uXtLi4IweKh'},
        defined_tags={
            'EXAMPLE_KEY_DSdk0': {
                'EXAMPLE_KEY_MPJ3X': 'EXAMPLE--Value'}}),
    opc_retry_token="EXAMPLE-opcRetryToken-Value",
    opc_request_id="MEYBYMCWH6ZMMEX4G0BT<unique_ID>")

# Get the data from response
print(create_schedule_response.data)

Was this article helpful?