// 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).
package main
import (
"context"
"fmt"
"github.com/oracle/oci-go-sdk/v65/certificatesmanagement"
"github.com/oracle/oci-go-sdk/v65/common"
"github.com/oracle/oci-go-sdk/v65/example/helpers"
)
func ExampleCreateCertificateAuthority() {
// 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.
client, err := certificatesmanagement.NewCertificatesManagementClientWithConfigurationProvider(common.DefaultConfigProvider())
helpers.FatalIfError(err)
// Create a request and dependent object(s).
req := certificatesmanagement.CreateCertificateAuthorityRequest{CreateCertificateAuthorityDetails: certificatesmanagement.CreateCertificateAuthorityDetails{FreeformTags: map[string]string{"EXAMPLE_KEY_hTzBQ": "EXAMPLE_VALUE_RIIYaBDJASJ9kkHZaJGC"},
KmsKeyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value"),
CertificateAuthorityConfig: certificatesmanagement.CreateRootCaManagedExternallyConfigDetails{CertificatePem: common.String("EXAMPLE-certificatePem-Value"),
VersionName: common.String("EXAMPLE-versionName-Value")},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_gUb2c": map[string]interface{}{"EXAMPLE_KEY_fooCM": "EXAMPLE--Value"}},
Name: common.String("EXAMPLE-name-Value"),
CertificateAuthorityRules: []certificatesmanagement.CertificateAuthorityRule{certificatesmanagement.CertificateAuthorityIssuanceRule{PathLengthConstraint: common.Int(327),
NameConstraint: &certificatesmanagement.NameConstraint{ExcludedSubtree: []certificatesmanagement.NameConstraintSubtreeNode{certificatesmanagement.NameConstraintSubtreeNode{Type: certificatesmanagement.NameConstraintTypeDirectoryName,
Value: common.String("EXAMPLE-value-Value")}},
PermittedSubtree: []certificatesmanagement.NameConstraintSubtreeNode{certificatesmanagement.NameConstraintSubtreeNode{Type: certificatesmanagement.NameConstraintTypeDirectoryName,
Value: common.String("EXAMPLE-value-Value")}}}}},
CertificateRevocationListDetails: &certificatesmanagement.CertificateRevocationListDetails{CustomFormattedUrls: []string{"EXAMPLE--Value"},
ObjectStorageConfig: &certificatesmanagement.ObjectStorageBucketConfigDetails{ObjectStorageBucketName: common.String("EXAMPLE-objectStorageBucketName-Value"),
ObjectStorageNamespace: common.String("EXAMPLE-objectStorageNamespace-Value"),
ObjectStorageObjectNameFormat: common.String("EXAMPLE-objectStorageObjectNameFormat-Value")}},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
Description: common.String("EXAMPLE-description-Value"),
ExternalKeyDescription: common.String("EXAMPLE-externalKeyDescription-Value")},
OpcRequestId: common.String("RSVRNIF8JZXUU2BIVMEM<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value")}
// Send the request using the service client
resp, err := client.CreateCertificateAuthority(context.Background(), req)
helpers.FatalIfError(err)
// Retrieve value from the response.
fmt.Println(resp)
}