// 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 * as certificatesmanagement from "oci-certificatesmanagement";
import common = require("oci-common");

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

const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();

(async () => {
    try {
     // Create a service client
     const client = new certificatesmanagement.CertificatesManagementClient({ authenticationDetailsProvider: provider });

     // Create a request and dependent object(s).
	const  updateCertificateAuthorityDetails = {
		description: "EXAMPLE-description-Value",
		currentVersionNumber: 957,
		certificateAuthorityConfig: {
			configType: "SUBORDINATE_CA_ISSUED_BY_INTERNAL_CA",			validity: {
				timeOfValidityNotBefore: new Date("Mon Feb 16 16:20:03 UTC 2037"),
				timeOfValidityNotAfter: new Date("Tue May 01 10:45:19 UTC 2018"),

				}
,
			versionName: "EXAMPLE-versionName-Value",
			stage: certificatesmanagement.models.UpdateCertificateAuthorityConfigDetails.Stage.Current

			}
,
		certificateRevocationListDetails: {
			objectStorageConfig: {
				objectStorageNamespace: "EXAMPLE-objectStorageNamespace-Value",
				objectStorageBucketName: "EXAMPLE-objectStorageBucketName-Value",
				objectStorageObjectNameFormat: "EXAMPLE-objectStorageObjectNameFormat-Value",

				}
,
			customFormattedUrls: ["EXAMPLE--Value"					],

			}
,
		externalKeyDescription: "EXAMPLE-externalKeyDescription-Value",
		freeformTags: {
			EXAMPLE_KEY_aCXgu :"EXAMPLE_VALUE_bwIel3QVqbdmRvklbYxB"
			},
		definedTags: {
			EXAMPLE_KEY_7PoJP :{
				EXAMPLE_KEY_7kpNq :"EXAMPLE--Value"
				}
			},
		certificateAuthorityRules: [{
				ruleType: "CERTIFICATE_AUTHORITY_ISSUANCE_RULE",				pathLengthConstraint: 163,
				nameConstraint: {
					permittedSubtree: [{
							type: certificatesmanagement.models.NameConstraintType.Ip,
							value: "EXAMPLE-value-Value",

							}
							],
					excludedSubtree: [{
							type: certificatesmanagement.models.NameConstraintType.Ip,
							value: "EXAMPLE-value-Value",

							}
							],

					}


				}
				],

		}

	const updateCertificateAuthorityRequest: certificatesmanagement.requests.UpdateCertificateAuthorityRequest = { 
	certificateAuthorityId: "ocid1.test.oc1..<unique_ID>EXAMPLE-certificateAuthorityId-Value",
	updateCertificateAuthorityDetails: updateCertificateAuthorityDetails,
	opcRequestId: "HHNXL5YQ62VQYORTDIQJ<unique_ID>",
	ifMatch: "EXAMPLE-ifMatch-Value",

		}; 


     // Send request to the Client.
     const updateCertificateAuthorityResponse = await client.updateCertificateAuthority(updateCertificateAuthorityRequest);
     }
     catch (error) {
         console.log("updateCertificateAuthority Failed with error  " + error);
     }
})();