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

require 'oci'
require 'date'

# 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::ConfigFileLoader.load_config

# Initialize service client with default config file
certificates_management_client =
  OCI::CertificatesManagement::CertificatesManagementClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
update_certificate_authority_response =
  certificates_management_client.update_certificate_authority(
    'ocid1.test.oc1..<unique_ID>EXAMPLE-certificateAuthorityId-Value',
    OCI::CertificatesManagement::Models::UpdateCertificateAuthorityDetails.new(
      description: 'EXAMPLE-description-Value',
      current_version_number: 650,
      certificate_authority_config:
        OCI::CertificatesManagement::Models::UpdateRootCaByGeneratingInternallyConfigDetails
          .new(
          config_type: 'ROOT_CA_GENERATED_INTERNALLY',
          version_name: 'EXAMPLE-versionName-Value',
          stage: 'CURRENT',
          validity:
            OCI::CertificatesManagement::Models::Validity.new(
              time_of_validity_not_after:
                DateTime.parse('2005-11-19T10:40:29.096Z'),
              time_of_validity_not_before:
                DateTime.parse('2021-05-15T17:40:42.892Z')
            )
        ),
      certificate_revocation_list_details:
        OCI::CertificatesManagement::Models::CertificateRevocationListDetails
          .new(
          object_storage_config:
            OCI::CertificatesManagement::Models::ObjectStorageBucketConfigDetails
              .new(
              object_storage_bucket_name:
                'EXAMPLE-objectStorageBucketName-Value',
              object_storage_object_name_format:
                'EXAMPLE-objectStorageObjectNameFormat-Value',
              object_storage_namespace: 'EXAMPLE-objectStorageNamespace-Value'
            ),
          custom_formatted_urls: %w[EXAMPLE--Value]
        ),
      freeform_tags: {
        'EXAMPLE_KEY_qXzP6' => 'EXAMPLE_VALUE_PvC4n8eoZ5B4wkElNiGH'
      },
      defined_tags: {
        'EXAMPLE_KEY_Mcnze' => { 'EXAMPLE_KEY_POxhC' => 'EXAMPLE--Value' }
      },
      certificate_authority_rules: [
        OCI::CertificatesManagement::Models::CertificateAuthorityIssuanceExpiryRule
          .new(
          rule_type: 'CERTIFICATE_AUTHORITY_ISSUANCE_EXPIRY_RULE',
          leaf_certificate_max_validity_duration:
            'EXAMPLE-leafCertificateMaxValidityDuration-Value',
          certificate_authority_max_validity_duration:
            'EXAMPLE-certificateAuthorityMaxValidityDuration-Value'
        )
      ]
    )
  )

# Get the data from response
puts "#{update_certificate_authority_response.data}"