From b31a6a963824dd854a7b272235873b14e5946d6b Mon Sep 17 00:00:00 2001 From: Francis Chuang Date: Thu, 9 Mar 2023 14:32:10 +1100 Subject: [PATCH] Add oci_certificates_certificate_bundle and oci_certificates_certificate_authority_bundle data sources --- internal/client/certificates_clients.go | 33 ++ ...cates_certificate_authority_bundle_test.go | 61 +++ .../certificates_certificate_bundle_test.go | 64 +++ internal/provider/register_datasource.go | 5 +- ...ertificate_authority_bundle_data_source.go | 224 ++++++++++ ...ificates_certificate_bundle_data_source.go | 272 +++++++++++++ .../certificates/register_datasource.go | 11 + .../oci-go-sdk/v65/certificates/ca_bundle.go | 45 +++ .../certificate_authority_bundle.go | 74 ++++ ...ate_authority_bundle_version_collection.go | 39 ++ ...ficate_authority_bundle_version_summary.go | 72 ++++ .../v65/certificates/certificate_bundle.go | 238 +++++++++++ .../certificate_bundle_public_only.go | 145 +++++++ .../certificate_bundle_version_collection.go | 39 ++ .../certificate_bundle_version_summary.go | 72 ++++ .../certificate_bundle_with_private_key.go | 151 +++++++ .../v65/certificates/certificates_client.go | 381 ++++++++++++++++++ .../get_ca_bundle_request_response.go | 93 +++++ ...icate_authority_bundle_request_response.go | 159 ++++++++ ...get_certificate_bundle_request_response.go | 207 ++++++++++ ...hority_bundle_versions_request_response.go | 183 +++++++++ ...ficate_bundle_versions_request_response.go | 183 +++++++++ .../v65/certificates/revocation_reason.go | 80 ++++ .../v65/certificates/revocation_status.go | 45 +++ .../oci-go-sdk/v65/certificates/validity.go | 44 ++ .../v65/certificates/version_stage.go | 72 ++++ ...certificate_authority_bundle.html.markdown | 71 ++++ ...tificates_certificate_bundle.html.markdown | 82 ++++ 28 files changed, 3144 insertions(+), 1 deletion(-) create mode 100644 internal/client/certificates_clients.go create mode 100644 internal/integrationtest/certificates_certificate_authority_bundle_test.go create mode 100644 internal/integrationtest/certificates_certificate_bundle_test.go create mode 100644 internal/service/certificates/certificates_certificate_authority_bundle_data_source.go create mode 100644 internal/service/certificates/certificates_certificate_bundle_data_source.go create mode 100644 internal/service/certificates/register_datasource.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/ca_bundle.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle_version_collection.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle_version_summary.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_public_only.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_version_collection.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_version_summary.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_with_private_key.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificates_client.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_ca_bundle_request_response.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_certificate_authority_bundle_request_response.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_certificate_bundle_request_response.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/list_certificate_authority_bundle_versions_request_response.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/list_certificate_bundle_versions_request_response.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/revocation_reason.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/revocation_status.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/validity.go create mode 100644 vendor/github.com/oracle/oci-go-sdk/v65/certificates/version_stage.go create mode 100644 website/docs/d/certificates_certificate_authority_bundle.html.markdown create mode 100644 website/docs/d/certificates_certificate_bundle.html.markdown diff --git a/internal/client/certificates_clients.go b/internal/client/certificates_clients.go new file mode 100644 index 00000000000..3956410e043 --- /dev/null +++ b/internal/client/certificates_clients.go @@ -0,0 +1,33 @@ +// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. +// Licensed under the Mozilla Public License v2.0 + +package client + +import ( + oci_certificates "github.com/oracle/oci-go-sdk/v65/certificates" + oci_common "github.com/oracle/oci-go-sdk/v65/common" +) + +func init() { + RegisterOracleClient("oci_certificates.CertificatesClient", &OracleClient{InitClientFn: initCertificatesCertificatesClient}) +} + +func initCertificatesCertificatesClient(configProvider oci_common.ConfigurationProvider, configureClient ConfigureClient, serviceClientOverrides ServiceClientOverrides) (interface{}, error) { + client, err := oci_certificates.NewCertificatesClientWithConfigurationProvider(configProvider) + if err != nil { + return nil, err + } + err = configureClient(&client.BaseClient) + if err != nil { + return nil, err + } + + if serviceClientOverrides.HostUrlOverride != "" { + client.Host = serviceClientOverrides.HostUrlOverride + } + return &client, nil +} + +func (m *OracleClients) CertificatesClient() *oci_certificates.CertificatesClient { + return m.GetClient("oci_certificates.CertificatesClient").(*oci_certificates.CertificatesClient) +} diff --git a/internal/integrationtest/certificates_certificate_authority_bundle_test.go b/internal/integrationtest/certificates_certificate_authority_bundle_test.go new file mode 100644 index 00000000000..fd5356f6033 --- /dev/null +++ b/internal/integrationtest/certificates_certificate_authority_bundle_test.go @@ -0,0 +1,61 @@ +// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. +// Licensed under the Mozilla Public License v2.0 + +package integrationtest + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + "github.com/oracle/terraform-provider-oci/httpreplay" + "github.com/oracle/terraform-provider-oci/internal/acctest" + + "github.com/oracle/terraform-provider-oci/internal/utils" +) + +var ( + CertificatesCertificateAuthorityBundleSingularDataSourceRepresentation = map[string]interface{}{ + "certificate_authority_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_certificates_management_certificate_authority.test_certificate_authority.id}`}, + "stage": acctest.Representation{RepType: acctest.Optional, Create: `CURRENT`}, + } + + CertificatesCertificateAuthorityBundleResourceConfig = acctest.GenerateResourceFromRepresentationMap("oci_certificates_management_certificate_authority", "test_certificate_authority", acctest.Required, acctest.Create, certificateAuthorityRepresentation) +) + +// issue-routing-tag: certificates/default +func TestCertificatesCertificateAuthorityBundleResource_basic(t *testing.T) { + httpreplay.SetScenario("TestCertificatesCertificateAuthorityBundleResource_basic") + defer httpreplay.SaveScenario() + + config := acctest.ProviderTestConfig() + + compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid") + compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId) + + singularDatasourceName := "data.oci_certificates_certificate_authority_bundle.test_certificate_authority_bundle" + + acctest.SaveConfigContent("", "", "", t) + acctest.ResourceTest(t, nil, []resource.TestStep{ + // verify singular datasource + { + Config: config + + acctest.GenerateDataSourceFromRepresentationMap("oci_certificates_certificate_authority_bundle", "test_certificate_authority_bundle", acctest.Optional, acctest.Create, CertificatesCertificateAuthorityBundleSingularDataSourceRepresentation) + + compartmentIdVariableStr + CertificatesCertificateAuthorityBundleResourceConfig, + Check: acctest.ComposeAggregateTestCheckFuncWrapper( + resource.TestCheckResourceAttrSet(singularDatasourceName, "cert_chain_pem"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_authority_id"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_authority_name"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_pem"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "serial_number"), + resource.TestCheckResourceAttr(singularDatasourceName, "stages.#", "2"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"), + resource.TestCheckResourceAttr(singularDatasourceName, "validity.#", "1"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "validity.0.time_of_validity_not_before"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "validity.0.time_of_validity_not_after"), + resource.TestCheckResourceAttr(singularDatasourceName, "version_number", "1"), + ), + }, + }) +} diff --git a/internal/integrationtest/certificates_certificate_bundle_test.go b/internal/integrationtest/certificates_certificate_bundle_test.go new file mode 100644 index 00000000000..d8aae41c73a --- /dev/null +++ b/internal/integrationtest/certificates_certificate_bundle_test.go @@ -0,0 +1,64 @@ +// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. +// Licensed under the Mozilla Public License v2.0 + +package integrationtest + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + "github.com/oracle/terraform-provider-oci/httpreplay" + "github.com/oracle/terraform-provider-oci/internal/acctest" + + "github.com/oracle/terraform-provider-oci/internal/utils" +) + +var ( + CertificatesCertificateBundleSingularDataSourceRepresentation = map[string]interface{}{ + "certificate_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_certificates_management_certificate.test_certificate.id}`}, + "certificate_bundle_type": acctest.Representation{RepType: acctest.Optional, Create: `CERTIFICATE_CONTENT_WITH_PRIVATE_KEY`}, + "stage": acctest.Representation{RepType: acctest.Optional, Create: `CURRENT`}, + } + + CertificatesCertificateBundleResourceConfig = acctest.GenerateResourceFromRepresentationMap("oci_certificates_management_certificate", "test_certificate", acctest.Required, acctest.Create, certificatesManagementCertificateRepresentation) +) + +// issue-routing-tag: certificates/default +func TestCertificatesCertificateBundleResource_basic(t *testing.T) { + httpreplay.SetScenario("TestCertificatesCertificateBundleResource_basic") + defer httpreplay.SaveScenario() + + config := acctest.ProviderTestConfig() + + compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid") + compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId) + + singularDatasourceName := "data.oci_certificates_certificate_bundle.test_certificate_bundle" + + acctest.SaveConfigContent("", "", "", t) + acctest.ResourceTest(t, nil, []resource.TestStep{ + // verify singular datasource + { + Config: config + + acctest.GenerateDataSourceFromRepresentationMap("oci_certificates_certificate_bundle", "test_certificate_bundle", acctest.Optional, acctest.Create, CertificatesCertificateBundleSingularDataSourceRepresentation) + + compartmentIdVariableStr + CertificatesCertificateBundleResourceConfig, + Check: acctest.ComposeAggregateTestCheckFuncWrapper( + resource.TestCheckResourceAttrSet(singularDatasourceName, "cert_chain_pem"), + resource.TestCheckResourceAttr(singularDatasourceName, "certificate_bundle_type", "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_id"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_name"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_pem"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "private_key_pem"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "serial_number"), + resource.TestCheckResourceAttr(singularDatasourceName, "stages.#", "2"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"), + resource.TestCheckResourceAttr(singularDatasourceName, "validity.#", "1"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "validity.0.time_of_validity_not_before"), + resource.TestCheckResourceAttrSet(singularDatasourceName, "validity.0.time_of_validity_not_after"), + resource.TestCheckResourceAttr(singularDatasourceName, "version_number", "1"), + ), + }, + }) +} diff --git a/internal/provider/register_datasource.go b/internal/provider/register_datasource.go index 3932fa23fc9..b6272e82f1f 100644 --- a/internal/provider/register_datasource.go +++ b/internal/provider/register_datasource.go @@ -26,6 +26,7 @@ import ( tf_blockchain "github.com/oracle/terraform-provider-oci/internal/service/blockchain" tf_budget "github.com/oracle/terraform-provider-oci/internal/service/budget" tf_capacity_management "github.com/oracle/terraform-provider-oci/internal/service/capacity_management" + tf_certificates "github.com/oracle/terraform-provider-oci/internal/service/certificates" tf_certificates_management "github.com/oracle/terraform-provider-oci/internal/service/certificates_management" tf_cloud_bridge "github.com/oracle/terraform-provider-oci/internal/service/cloud_bridge" tf_cloud_guard "github.com/oracle/terraform-provider-oci/internal/service/cloud_guard" @@ -194,6 +195,9 @@ func init() { if common.CheckForEnabledServices("capacitymanagement") { tf_capacity_management.RegisterDatasource() } + if common.CheckForEnabledServices("certificates") { + tf_certificates.RegisterDatasource() + } if common.CheckForEnabledServices("certificatesmanagement") { tf_certificates_management.RegisterDatasource() } @@ -500,5 +504,4 @@ func init() { if common.CheckForEnabledServices("zpr") { tf_zpr.RegisterDatasource() } - } diff --git a/internal/service/certificates/certificates_certificate_authority_bundle_data_source.go b/internal/service/certificates/certificates_certificate_authority_bundle_data_source.go new file mode 100644 index 00000000000..40e665b2268 --- /dev/null +++ b/internal/service/certificates/certificates_certificate_authority_bundle_data_source.go @@ -0,0 +1,224 @@ +// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. +// Licensed under the Mozilla Public License v2.0 + +package certificates + +import ( + "context" + "fmt" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + oci_certificates "github.com/oracle/oci-go-sdk/v65/certificates" + "github.com/oracle/terraform-provider-oci/internal/client" + "github.com/oracle/terraform-provider-oci/internal/tfresource" +) + +func CertificatesCertificateAuthorityBundleDataSource() *schema.Resource { + return &schema.Resource{ + Read: readCertificatesCertificateAuthorityBundle, + Schema: map[string]*schema.Schema{ + "cert_chain_pem": { + Type: schema.TypeString, + Computed: true, + }, + "certificate_authority_id": { + Type: schema.TypeString, + Required: true, + }, + "certificate_authority_name": { + Type: schema.TypeString, + Computed: true, + }, + "certificate_pem": { + Type: schema.TypeString, + Computed: true, + }, + "certificate_authority_version_name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "revocation_status": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "time_revoked": { + Type: schema.TypeString, + Required: true, + }, + "revocation_reason": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + "serial_number": { + Type: schema.TypeString, + Computed: true, + }, + "stage": { + Type: schema.TypeString, + DiffSuppressFunc: tfresource.EqualIgnoreCaseSuppressDiff, + ValidateFunc: validation.StringInSlice([]string{ + "CURRENT", + "PENDING", + "LATEST", + "PREVIOUS", + "DEPRECATED", + }, true), + Optional: true, + }, + "stages": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "time_created": { + Type: schema.TypeString, + Computed: true, + }, + "validity": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "time_of_validity_not_before": { + Type: schema.TypeString, + Required: true, + }, + "time_of_validity_not_after": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + "version_name": { + Type: schema.TypeString, + Computed: true, + }, + "version_number": { + Type: schema.TypeString, + Computed: true, + Optional: true, + }, + }, + } +} + +func readCertificatesCertificateAuthorityBundle(d *schema.ResourceData, m interface{}) error { + sync := &CertificatesCertificateAuthorityBundleDataSourceCrud{} + sync.D = d + sync.Client = m.(*client.OracleClients).CertificatesClient() + + return tfresource.ReadResource(sync) +} + +type CertificatesCertificateAuthorityBundleDataSourceCrud struct { + D *schema.ResourceData + Client *oci_certificates.CertificatesClient + Res *oci_certificates.GetCertificateAuthorityBundleResponse +} + +func (s *CertificatesCertificateAuthorityBundleDataSourceCrud) VoidState() { + s.D.SetId("") +} + +func (s *CertificatesCertificateAuthorityBundleDataSourceCrud) Get() error { + request := oci_certificates.GetCertificateAuthorityBundleRequest{} + + if certificateAuthorityId, ok := s.D.GetOkExists("certificate_authority_id"); ok { + tmp := certificateAuthorityId.(string) + request.CertificateAuthorityId = &tmp + } + + if versionNumber, ok := s.D.GetOkExists("version_number"); ok { + tmp := versionNumber.(string) + tmpInt64, err := strconv.ParseInt(tmp, 10, 64) + if err != nil { + return fmt.Errorf("unable to convert versionNumber string: %s to an int64 and encountered error: %v", tmp, err) + } + request.VersionNumber = &tmpInt64 + } + + if certificateAuthorityVersionName, ok := s.D.GetOkExists("certificate_authority_version_name"); ok { + tmp := certificateAuthorityVersionName.(string) + request.CertificateAuthorityVersionName = &tmp + } + + if stage, ok := s.D.GetOkExists("stage"); ok { + request.Stage = oci_certificates.GetCertificateAuthorityBundleStageEnum(stage.(string)) + } + + request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(false, "certificates") + + response, err := s.Client.GetCertificateAuthorityBundle(context.Background(), request) + if err != nil { + return err + } + + s.Res = &response + return nil +} + +func (s *CertificatesCertificateAuthorityBundleDataSourceCrud) SetData() error { + if s.Res == nil { + return nil + } + + s.D.SetId(*s.Res.CertificateAuthorityId) + + if s.Res.CertChainPem != nil { + s.D.Set("cert_chain_pem", *s.Res.CertChainPem) + } + + if s.Res.CertificateAuthorityName != nil { + s.D.Set("certificate_authority_name", *s.Res.CertificateAuthorityName) + } + + if s.Res.CertificatePem != nil { + s.D.Set("certificate_pem", *s.Res.CertificatePem) + } + + if s.Res.RevocationStatus != nil { + s.D.Set("revocation_status", []interface{}{revocationStatusToMap(s.Res.RevocationStatus)}) + } else { + s.D.Set("revocation_status", nil) + } + + if s.Res.SerialNumber != nil { + s.D.Set("serial_number", *s.Res.SerialNumber) + } + + stages := []interface{}{} + for _, item := range s.Res.Stages { + stages = append(stages, item) + } + s.D.Set("stages", stages) + + if s.Res.TimeCreated != nil { + s.D.Set("time_created", s.Res.TimeCreated.String()) + } + + if s.Res.Validity != nil { + s.D.Set("validity", []interface{}{validityToMap(s.Res.Validity)}) + } else { + s.D.Set("validity", nil) + } + + if s.Res.VersionName != nil { + s.D.Set("version_name", *s.Res.VersionName) + } + + if s.Res.VersionNumber != nil { + s.D.Set("version_number", strconv.FormatInt(*s.Res.VersionNumber, 10)) + } + + return nil +} diff --git a/internal/service/certificates/certificates_certificate_bundle_data_source.go b/internal/service/certificates/certificates_certificate_bundle_data_source.go new file mode 100644 index 00000000000..bca920315fe --- /dev/null +++ b/internal/service/certificates/certificates_certificate_bundle_data_source.go @@ -0,0 +1,272 @@ +// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. +// Licensed under the Mozilla Public License v2.0 + +package certificates + +import ( + "context" + "fmt" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + oci_certificates "github.com/oracle/oci-go-sdk/v65/certificates" + "github.com/oracle/terraform-provider-oci/internal/client" + "github.com/oracle/terraform-provider-oci/internal/tfresource" +) + +func CertificatesCertificateBundleDataSource() *schema.Resource { + return &schema.Resource{ + Read: readCertificatesCertificateBundle, + Schema: map[string]*schema.Schema{ + "cert_chain_pem": { + Type: schema.TypeString, + Computed: true, + }, + "certificate_bundle_type": { + Type: schema.TypeString, + DiffSuppressFunc: tfresource.EqualIgnoreCaseSuppressDiff, + ValidateFunc: validation.StringInSlice([]string{ + "CERTIFICATE_CONTENT_PUBLIC_ONLY", + "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY", + }, true), + Optional: true, + Computed: true, + }, + "certificate_id": { + Type: schema.TypeString, + Required: true, + }, + "certificate_name": { + Type: schema.TypeString, + Computed: true, + }, + "certificate_pem": { + Type: schema.TypeString, + Computed: true, + }, + "certificate_version_name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "private_key_pem": { + Type: schema.TypeString, + Computed: true, + }, + "private_key_pem_passphrase": { + Type: schema.TypeString, + Computed: true, + }, + "revocation_status": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "time_revoked": { + Type: schema.TypeString, + Required: true, + }, + "revocation_reason": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + "serial_number": { + Type: schema.TypeString, + Computed: true, + }, + "stage": { + Type: schema.TypeString, + DiffSuppressFunc: tfresource.EqualIgnoreCaseSuppressDiff, + ValidateFunc: validation.StringInSlice([]string{ + "CURRENT", + "PENDING", + "LATEST", + "PREVIOUS", + "DEPRECATED", + }, true), + Optional: true, + }, + "stages": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "time_created": { + Type: schema.TypeString, + Computed: true, + }, + "validity": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "time_of_validity_not_before": { + Type: schema.TypeString, + Required: true, + }, + "time_of_validity_not_after": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + "version_number": { + Type: schema.TypeString, + Computed: true, + Optional: true, + }, + }, + } +} + +func readCertificatesCertificateBundle(d *schema.ResourceData, m interface{}) error { + sync := &CertificatesCertificateBundleDataSourceCrud{} + sync.D = d + sync.Client = m.(*client.OracleClients).CertificatesClient() + + return tfresource.ReadResource(sync) +} + +type CertificatesCertificateBundleDataSourceCrud struct { + D *schema.ResourceData + Client *oci_certificates.CertificatesClient + Res *oci_certificates.GetCertificateBundleResponse +} + +func (s *CertificatesCertificateBundleDataSourceCrud) VoidState() { + s.D.SetId("") +} + +func (s *CertificatesCertificateBundleDataSourceCrud) Get() error { + request := oci_certificates.GetCertificateBundleRequest{} + + if certificateId, ok := s.D.GetOkExists("certificate_id"); ok { + tmp := certificateId.(string) + request.CertificateId = &tmp + } + + if versionNumber, ok := s.D.GetOkExists("version_number"); ok { + tmp := versionNumber.(string) + tmpInt64, err := strconv.ParseInt(tmp, 10, 64) + if err != nil { + return fmt.Errorf("unable to convert versionNumber string: %s to an int64 and encountered error: %v", tmp, err) + } + request.VersionNumber = &tmpInt64 + } + + if certificateVersionName, ok := s.D.GetOkExists("certificate_version_name"); ok { + tmp := certificateVersionName.(string) + request.CertificateVersionName = &tmp + } + + if stage, ok := s.D.GetOkExists("stage"); ok { + request.Stage = oci_certificates.GetCertificateBundleStageEnum(stage.(string)) + } + + if certificateBundleType, ok := s.D.GetOkExists("certificate_bundle_type"); ok { + request.CertificateBundleType = oci_certificates.GetCertificateBundleCertificateBundleTypeEnum(certificateBundleType.(string)) + } + + request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(false, "certificates") + + response, err := s.Client.GetCertificateBundle(context.Background(), request) + if err != nil { + return err + } + + s.Res = &response + return nil +} + +func (s *CertificatesCertificateBundleDataSourceCrud) SetData() error { + if s.Res == nil { + return nil + } + + s.D.SetId(*s.Res.GetCertificateId()) + + if s.Res.GetCertificateName() != nil { + s.D.Set("certificate_name", *s.Res.GetCertificateName()) + } + + if s.Res.GetVersionNumber() != nil { + s.D.Set("version_number", strconv.FormatInt(*s.Res.GetVersionNumber(), 10)) + } + + if s.Res.GetSerialNumber() != nil { + s.D.Set("serial_number", *s.Res.GetSerialNumber()) + } + + if s.Res.GetTimeCreated() != nil { + s.D.Set("time_created", s.Res.GetTimeCreated().String()) + } + + if s.Res.GetValidity() != nil { + s.D.Set("validity", []interface{}{validityToMap(s.Res.GetValidity())}) + } else { + s.D.Set("validity", nil) + } + + stages := []interface{}{} + for _, item := range s.Res.GetStages() { + stages = append(stages, item) + } + s.D.Set("stages", stages) + + if s.Res.GetCertificatePem() != nil { + s.D.Set("certificate_pem", *s.Res.GetCertificatePem()) + } + + if s.Res.GetCertChainPem() != nil { + s.D.Set("cert_chain_pem", *s.Res.GetCertChainPem()) + } + + if s.Res.GetVersionName() != nil { + s.D.Set("version_name", *s.Res.GetVersionName()) + } + + if s.Res.GetRevocationStatus() != nil { + s.D.Set("revocation_status", []interface{}{revocationStatusToMap(s.Res.GetRevocationStatus())}) + } else { + s.D.Set("revocation_status", nil) + } + + if bundle, ok := s.Res.CertificateBundle.(oci_certificates.CertificateBundleWithPrivateKey); ok { + if bundle.PrivateKeyPem != nil { + s.D.Set("private_key_pem", *bundle.PrivateKeyPem) + } + if bundle.PrivateKeyPemPassphrase != nil { + s.D.Set("private_key_passphrase", *bundle.PrivateKeyPemPassphrase) + } + s.D.Set("certificate_bundle_type", "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY") + } else { + s.D.Set("certificate_bundle_type", "CERTIFICATE_CONTENT_PUBLIC_ONLY") + } + + return nil +} + +func validityToMap(obj *oci_certificates.Validity) map[string]interface{} { + result := map[string]interface{}{ + "time_of_validity_not_before": obj.TimeOfValidityNotBefore.String(), + "time_of_validity_not_after": obj.TimeOfValidityNotAfter.String(), + } + + return result +} + +func revocationStatusToMap(obj *oci_certificates.RevocationStatus) map[string]interface{} { + result := map[string]interface{}{ + "time_revoked": obj.TimeRevoked.String(), + "revocation_reason": obj.RevocationReason, + } + + return result +} diff --git a/internal/service/certificates/register_datasource.go b/internal/service/certificates/register_datasource.go new file mode 100644 index 00000000000..cde593914c8 --- /dev/null +++ b/internal/service/certificates/register_datasource.go @@ -0,0 +1,11 @@ +// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. +// Licensed under the Mozilla Public License v2.0 + +package certificates + +import "github.com/oracle/terraform-provider-oci/internal/tfresource" + +func RegisterDatasource() { + tfresource.RegisterDatasource("oci_certificates_certificate_bundle", CertificatesCertificateBundleDataSource()) + tfresource.RegisterDatasource("oci_certificates_certificate_authority_bundle", CertificatesCertificateAuthorityBundleDataSource()) +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/ca_bundle.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/ca_bundle.go new file mode 100644 index 00000000000..0428309c885 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/ca_bundle.go @@ -0,0 +1,45 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "strings" +) + +// CaBundle The contents of the CA bundle (root and intermediate certificates), properties of the CA bundle, and user-provided contextual metadata for the CA bundle. +type CaBundle struct { + + // The OCID of the CA bundle. + Id *string `mandatory:"true" json:"id"` + + // A user-friendly name for the CA bundle. Names are unique within a compartment. Valid characters include uppercase or lowercase letters, numbers, hyphens, underscores, and periods. + Name *string `mandatory:"true" json:"name"` + + // Certificates (in PEM format) in the CA bundle. Can be of arbitrary length. + CaBundlePem *string `mandatory:"true" json:"caBundlePem"` +} + +func (m CaBundle) String() string { + return common.PointerString(m) +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (m CaBundle) ValidateEnumValue() (bool, error) { + errMessage := []string{} + + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle.go new file mode 100644 index 00000000000..123002d4df8 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle.go @@ -0,0 +1,74 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "strings" +) + +// CertificateAuthorityBundle The contents of the certificate, properties of the certificate (and certificate version), and user-provided contextual metadata for the certificate. +type CertificateAuthorityBundle struct { + + // The OCID of the certificate authority (CA). + CertificateAuthorityId *string `mandatory:"true" json:"certificateAuthorityId"` + + // The name of the CA. + CertificateAuthorityName *string `mandatory:"true" json:"certificateAuthorityName"` + + // A unique certificate identifier used in certificate revocation tracking, formatted as octets. + // Example: `03 AC FC FA CC B3 CB 02 B8 F8 DE F5 85 E7 7B FF` + SerialNumber *string `mandatory:"true" json:"serialNumber"` + + // The certificate (in PEM format) for this CA version. + CertificatePem *string `mandatory:"true" json:"certificatePem"` + + // A property indicating when the CA was created, expressed in RFC 3339 (https://tools.ietf.org/html/rfc3339) timestamp format. + // Example: `2019-04-03T21:10:29.600Z` + TimeCreated *common.SDKTime `mandatory:"true" json:"timeCreated"` + + // The version number of the CA. + VersionNumber *int64 `mandatory:"true" json:"versionNumber"` + + Validity *Validity `mandatory:"true" json:"validity"` + + // A list of rotation states for this CA. + Stages []VersionStageEnum `mandatory:"true" json:"stages"` + + // The certificate chain (in PEM format) for this CA version. + CertChainPem *string `mandatory:"false" json:"certChainPem"` + + // The name of the CA. + VersionName *string `mandatory:"false" json:"versionName"` + + RevocationStatus *RevocationStatus `mandatory:"false" json:"revocationStatus"` +} + +func (m CertificateAuthorityBundle) String() string { + return common.PointerString(m) +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (m CertificateAuthorityBundle) ValidateEnumValue() (bool, error) { + errMessage := []string{} + for _, val := range m.Stages { + if _, ok := GetMappingVersionStageEnum(string(val)); !ok && val != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for Stages: %s. Supported values are: %s.", val, strings.Join(GetVersionStageEnumStringValues(), ","))) + } + } + + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle_version_collection.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle_version_collection.go new file mode 100644 index 00000000000..882a9ecf379 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle_version_collection.go @@ -0,0 +1,39 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "strings" +) + +// CertificateAuthorityBundleVersionCollection The results of a certificate authority (CA) version search. Results contain CA version summary objects and other data. +type CertificateAuthorityBundleVersionCollection struct { + + // A list of CA version summary objects. + Items []CertificateAuthorityBundleVersionSummary `mandatory:"true" json:"items"` +} + +func (m CertificateAuthorityBundleVersionCollection) String() string { + return common.PointerString(m) +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (m CertificateAuthorityBundleVersionCollection) ValidateEnumValue() (bool, error) { + errMessage := []string{} + + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle_version_summary.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle_version_summary.go new file mode 100644 index 00000000000..f7d5c8fe5ed --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_authority_bundle_version_summary.go @@ -0,0 +1,72 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "strings" +) + +// CertificateAuthorityBundleVersionSummary The properties of a version of a bundle for a certificate authority (CA). Certificate authority bundle version summary objects do not include the actual contents of the certificate. +type CertificateAuthorityBundleVersionSummary struct { + + // The OCID of the certificate authority (CA). + CertificateAuthorityId *string `mandatory:"true" json:"certificateAuthorityId"` + + // An optional property indicating when the CA version was created, expressed in RFC 3339 (https://tools.ietf.org/html/rfc3339) timestamp format. + // Example: `2019-04-03T21:10:29.600Z` + TimeCreated *common.SDKTime `mandatory:"true" json:"timeCreated"` + + // The version number of the CA. + VersionNumber *int64 `mandatory:"true" json:"versionNumber"` + + // The name of the CA. + CertificateAuthorityName *string `mandatory:"true" json:"certificateAuthorityName"` + + // A list of rotation states for this CA version. + Stages []VersionStageEnum `mandatory:"true" json:"stages"` + + // A unique certificate identifier used in certificate revocation tracking, formatted as octets. + // Example: `03 AC FC FA CC B3 CB 02 B8 F8 DE F5 85 E7 7B FF` + SerialNumber *string `mandatory:"false" json:"serialNumber"` + + // The name of the CA version. When this value is not null, the name is unique across CA versions for a given CA. + VersionName *string `mandatory:"false" json:"versionName"` + + // An optional property indicating when to delete the CA version, expressed in RFC 3339 (https://tools.ietf.org/html/rfc3339) timestamp format. + // Example: `2019-04-03T21:10:29.600Z` + TimeOfDeletion *common.SDKTime `mandatory:"false" json:"timeOfDeletion"` + + Validity *Validity `mandatory:"false" json:"validity"` + + RevocationStatus *RevocationStatus `mandatory:"false" json:"revocationStatus"` +} + +func (m CertificateAuthorityBundleVersionSummary) String() string { + return common.PointerString(m) +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (m CertificateAuthorityBundleVersionSummary) ValidateEnumValue() (bool, error) { + errMessage := []string{} + for _, val := range m.Stages { + if _, ok := GetMappingVersionStageEnum(string(val)); !ok && val != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for Stages: %s. Supported values are: %s.", val, strings.Join(GetVersionStageEnumStringValues(), ","))) + } + } + + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle.go new file mode 100644 index 00000000000..a5c9cf785b5 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle.go @@ -0,0 +1,238 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "encoding/json" + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "strings" +) + +// CertificateBundle The contents of the certificate, properties of the certificate (and certificate version), and user-provided contextual metadata for the certificate. +type CertificateBundle interface { + + // The OCID of the certificate. + GetCertificateId() *string + + // The name of the certificate. + GetCertificateName() *string + + // The version number of the certificate. + GetVersionNumber() *int64 + + // A unique certificate identifier used in certificate revocation tracking, formatted as octets. + // Example: `03 AC FC FA CC B3 CB 02 B8 F8 DE F5 85 E7 7B FF` + GetSerialNumber() *string + + // An optional property indicating when the certificate version was created, expressed in RFC 3339 (https://tools.ietf.org/html/rfc3339) timestamp format. + // Example: `2019-04-03T21:10:29.600Z` + GetTimeCreated() *common.SDKTime + + GetValidity() *Validity + + // A list of rotation states for the certificate bundle. + GetStages() []VersionStageEnum + + // The certificate in PEM format. + GetCertificatePem() *string + + // The certificate chain (in PEM format) for the certificate bundle. + GetCertChainPem() *string + + // The name of the certificate version. + GetVersionName() *string + + GetRevocationStatus() *RevocationStatus +} + +type certificatebundle struct { + JsonData []byte + CertificatePem *string `mandatory:"false" json:"certificatePem"` + CertChainPem *string `mandatory:"false" json:"certChainPem"` + VersionName *string `mandatory:"false" json:"versionName"` + RevocationStatus *RevocationStatus `mandatory:"false" json:"revocationStatus"` + CertificateId *string `mandatory:"true" json:"certificateId"` + CertificateName *string `mandatory:"true" json:"certificateName"` + VersionNumber *int64 `mandatory:"true" json:"versionNumber"` + SerialNumber *string `mandatory:"true" json:"serialNumber"` + TimeCreated *common.SDKTime `mandatory:"true" json:"timeCreated"` + Validity *Validity `mandatory:"true" json:"validity"` + Stages []VersionStageEnum `mandatory:"true" json:"stages"` + CertificateBundleType string `json:"certificateBundleType"` +} + +// UnmarshalJSON unmarshals json +func (m *certificatebundle) UnmarshalJSON(data []byte) error { + m.JsonData = data + type Unmarshalercertificatebundle certificatebundle + s := struct { + Model Unmarshalercertificatebundle + }{} + err := json.Unmarshal(data, &s.Model) + if err != nil { + return err + } + m.CertificateId = s.Model.CertificateId + m.CertificateName = s.Model.CertificateName + m.VersionNumber = s.Model.VersionNumber + m.SerialNumber = s.Model.SerialNumber + m.TimeCreated = s.Model.TimeCreated + m.Validity = s.Model.Validity + m.Stages = s.Model.Stages + m.CertificatePem = s.Model.CertificatePem + m.CertChainPem = s.Model.CertChainPem + m.VersionName = s.Model.VersionName + m.RevocationStatus = s.Model.RevocationStatus + m.CertificateBundleType = s.Model.CertificateBundleType + + return err +} + +// UnmarshalPolymorphicJSON unmarshals polymorphic json +func (m *certificatebundle) UnmarshalPolymorphicJSON(data []byte) (interface{}, error) { + + if data == nil || string(data) == "null" { + return nil, nil + } + + var err error + switch m.CertificateBundleType { + case "CERTIFICATE_CONTENT_PUBLIC_ONLY": + mm := CertificateBundlePublicOnly{} + err = json.Unmarshal(data, &mm) + return mm, err + case "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY": + mm := CertificateBundleWithPrivateKey{} + err = json.Unmarshal(data, &mm) + return mm, err + default: + common.Logf("Recieved unsupported enum value for CertificateBundle: %s.", m.CertificateBundleType) + return *m, nil + } +} + +// GetCertificatePem returns CertificatePem +func (m certificatebundle) GetCertificatePem() *string { + return m.CertificatePem +} + +// GetCertChainPem returns CertChainPem +func (m certificatebundle) GetCertChainPem() *string { + return m.CertChainPem +} + +// GetVersionName returns VersionName +func (m certificatebundle) GetVersionName() *string { + return m.VersionName +} + +// GetRevocationStatus returns RevocationStatus +func (m certificatebundle) GetRevocationStatus() *RevocationStatus { + return m.RevocationStatus +} + +// GetCertificateId returns CertificateId +func (m certificatebundle) GetCertificateId() *string { + return m.CertificateId +} + +// GetCertificateName returns CertificateName +func (m certificatebundle) GetCertificateName() *string { + return m.CertificateName +} + +// GetVersionNumber returns VersionNumber +func (m certificatebundle) GetVersionNumber() *int64 { + return m.VersionNumber +} + +// GetSerialNumber returns SerialNumber +func (m certificatebundle) GetSerialNumber() *string { + return m.SerialNumber +} + +// GetTimeCreated returns TimeCreated +func (m certificatebundle) GetTimeCreated() *common.SDKTime { + return m.TimeCreated +} + +// GetValidity returns Validity +func (m certificatebundle) GetValidity() *Validity { + return m.Validity +} + +// GetStages returns Stages +func (m certificatebundle) GetStages() []VersionStageEnum { + return m.Stages +} + +func (m certificatebundle) String() string { + return common.PointerString(m) +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (m certificatebundle) ValidateEnumValue() (bool, error) { + errMessage := []string{} + for _, val := range m.Stages { + if _, ok := GetMappingVersionStageEnum(string(val)); !ok && val != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for Stages: %s. Supported values are: %s.", val, strings.Join(GetVersionStageEnumStringValues(), ","))) + } + } + + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} + +// CertificateBundleCertificateBundleTypeEnum Enum with underlying type: string +type CertificateBundleCertificateBundleTypeEnum string + +// Set of constants representing the allowable values for CertificateBundleCertificateBundleTypeEnum +const ( + CertificateBundleCertificateBundleTypePublicOnly CertificateBundleCertificateBundleTypeEnum = "CERTIFICATE_CONTENT_PUBLIC_ONLY" + CertificateBundleCertificateBundleTypeWithPrivateKey CertificateBundleCertificateBundleTypeEnum = "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY" +) + +var mappingCertificateBundleCertificateBundleTypeEnum = map[string]CertificateBundleCertificateBundleTypeEnum{ + "CERTIFICATE_CONTENT_PUBLIC_ONLY": CertificateBundleCertificateBundleTypePublicOnly, + "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY": CertificateBundleCertificateBundleTypeWithPrivateKey, +} + +var mappingCertificateBundleCertificateBundleTypeEnumLowerCase = map[string]CertificateBundleCertificateBundleTypeEnum{ + "certificate_content_public_only": CertificateBundleCertificateBundleTypePublicOnly, + "certificate_content_with_private_key": CertificateBundleCertificateBundleTypeWithPrivateKey, +} + +// GetCertificateBundleCertificateBundleTypeEnumValues Enumerates the set of values for CertificateBundleCertificateBundleTypeEnum +func GetCertificateBundleCertificateBundleTypeEnumValues() []CertificateBundleCertificateBundleTypeEnum { + values := make([]CertificateBundleCertificateBundleTypeEnum, 0) + for _, v := range mappingCertificateBundleCertificateBundleTypeEnum { + values = append(values, v) + } + return values +} + +// GetCertificateBundleCertificateBundleTypeEnumStringValues Enumerates the set of values in String for CertificateBundleCertificateBundleTypeEnum +func GetCertificateBundleCertificateBundleTypeEnumStringValues() []string { + return []string{ + "CERTIFICATE_CONTENT_PUBLIC_ONLY", + "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY", + } +} + +// GetMappingCertificateBundleCertificateBundleTypeEnum performs case Insensitive comparison on enum value and return the desired enum +func GetMappingCertificateBundleCertificateBundleTypeEnum(val string) (CertificateBundleCertificateBundleTypeEnum, bool) { + enum, ok := mappingCertificateBundleCertificateBundleTypeEnumLowerCase[strings.ToLower(val)] + return enum, ok +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_public_only.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_public_only.go new file mode 100644 index 00000000000..d85860f0dd1 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_public_only.go @@ -0,0 +1,145 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "encoding/json" + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "strings" +) + +// CertificateBundlePublicOnly A certificate bundle, not including the private key. +type CertificateBundlePublicOnly struct { + + // The OCID of the certificate. + CertificateId *string `mandatory:"true" json:"certificateId"` + + // The name of the certificate. + CertificateName *string `mandatory:"true" json:"certificateName"` + + // The version number of the certificate. + VersionNumber *int64 `mandatory:"true" json:"versionNumber"` + + // A unique certificate identifier used in certificate revocation tracking, formatted as octets. + // Example: `03 AC FC FA CC B3 CB 02 B8 F8 DE F5 85 E7 7B FF` + SerialNumber *string `mandatory:"true" json:"serialNumber"` + + // An optional property indicating when the certificate version was created, expressed in RFC 3339 (https://tools.ietf.org/html/rfc3339) timestamp format. + // Example: `2019-04-03T21:10:29.600Z` + TimeCreated *common.SDKTime `mandatory:"true" json:"timeCreated"` + + Validity *Validity `mandatory:"true" json:"validity"` + + // The certificate in PEM format. + CertificatePem *string `mandatory:"false" json:"certificatePem"` + + // The certificate chain (in PEM format) for the certificate bundle. + CertChainPem *string `mandatory:"false" json:"certChainPem"` + + // The name of the certificate version. + VersionName *string `mandatory:"false" json:"versionName"` + + RevocationStatus *RevocationStatus `mandatory:"false" json:"revocationStatus"` + + // A list of rotation states for the certificate bundle. + Stages []VersionStageEnum `mandatory:"true" json:"stages"` +} + +// GetCertificateId returns CertificateId +func (m CertificateBundlePublicOnly) GetCertificateId() *string { + return m.CertificateId +} + +// GetCertificateName returns CertificateName +func (m CertificateBundlePublicOnly) GetCertificateName() *string { + return m.CertificateName +} + +// GetVersionNumber returns VersionNumber +func (m CertificateBundlePublicOnly) GetVersionNumber() *int64 { + return m.VersionNumber +} + +// GetSerialNumber returns SerialNumber +func (m CertificateBundlePublicOnly) GetSerialNumber() *string { + return m.SerialNumber +} + +// GetCertificatePem returns CertificatePem +func (m CertificateBundlePublicOnly) GetCertificatePem() *string { + return m.CertificatePem +} + +// GetCertChainPem returns CertChainPem +func (m CertificateBundlePublicOnly) GetCertChainPem() *string { + return m.CertChainPem +} + +// GetTimeCreated returns TimeCreated +func (m CertificateBundlePublicOnly) GetTimeCreated() *common.SDKTime { + return m.TimeCreated +} + +// GetValidity returns Validity +func (m CertificateBundlePublicOnly) GetValidity() *Validity { + return m.Validity +} + +// GetVersionName returns VersionName +func (m CertificateBundlePublicOnly) GetVersionName() *string { + return m.VersionName +} + +// GetStages returns Stages +func (m CertificateBundlePublicOnly) GetStages() []VersionStageEnum { + return m.Stages +} + +// GetRevocationStatus returns RevocationStatus +func (m CertificateBundlePublicOnly) GetRevocationStatus() *RevocationStatus { + return m.RevocationStatus +} + +func (m CertificateBundlePublicOnly) String() string { + return common.PointerString(m) +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (m CertificateBundlePublicOnly) ValidateEnumValue() (bool, error) { + errMessage := []string{} + + for _, val := range m.Stages { + if _, ok := GetMappingVersionStageEnum(string(val)); !ok && val != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for Stages: %s. Supported values are: %s.", val, strings.Join(GetVersionStageEnumStringValues(), ","))) + } + } + + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} + +// MarshalJSON marshals to json representation +func (m CertificateBundlePublicOnly) MarshalJSON() (buff []byte, e error) { + type MarshalTypeCertificateBundlePublicOnly CertificateBundlePublicOnly + s := struct { + DiscriminatorParam string `json:"certificateBundleType"` + MarshalTypeCertificateBundlePublicOnly + }{ + "CERTIFICATE_CONTENT_PUBLIC_ONLY", + (MarshalTypeCertificateBundlePublicOnly)(m), + } + + return json.Marshal(&s) +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_version_collection.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_version_collection.go new file mode 100644 index 00000000000..f453c0b78d5 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_version_collection.go @@ -0,0 +1,39 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "strings" +) + +// CertificateBundleVersionCollection The results of a certificate bundle versions search. Results contain certificate bundle version summary objects. +type CertificateBundleVersionCollection struct { + + // A list of certificate bundle version summary objects. + Items []CertificateBundleVersionSummary `mandatory:"true" json:"items"` +} + +func (m CertificateBundleVersionCollection) String() string { + return common.PointerString(m) +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (m CertificateBundleVersionCollection) ValidateEnumValue() (bool, error) { + errMessage := []string{} + + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_version_summary.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_version_summary.go new file mode 100644 index 00000000000..3e9672a51ad --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_version_summary.go @@ -0,0 +1,72 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "strings" +) + +// CertificateBundleVersionSummary The properties of the certificate bundle. Certificate bundle version summary objects do not include the actual contents of the certificate. +type CertificateBundleVersionSummary struct { + + // The OCID of the certificate. + CertificateId *string `mandatory:"true" json:"certificateId"` + + // The name of the certificate. + CertificateName *string `mandatory:"true" json:"certificateName"` + + // The version number of the certificate. + VersionNumber *int64 `mandatory:"true" json:"versionNumber"` + + // An optional property indicating when the certificate version was created, expressed in RFC 3339 (https://tools.ietf.org/html/rfc3339) timestamp format. + // Example: `2019-04-03T21:10:29.600Z` + TimeCreated *common.SDKTime `mandatory:"true" json:"timeCreated"` + + // A list of rotation states for this certificate bundle version. + Stages []VersionStageEnum `mandatory:"true" json:"stages"` + + // A unique certificate identifier used in certificate revocation tracking, formatted as octets. + // Example: `03 AC FC FA CC B3 CB 02 B8 F8 DE F5 85 E7 7B FF` + SerialNumber *string `mandatory:"false" json:"serialNumber"` + + // The name of the certificate version. + VersionName *string `mandatory:"false" json:"versionName"` + + Validity *Validity `mandatory:"false" json:"validity"` + + // An optional property indicating when to delete the certificate version, expressed in RFC 3339 (https://tools.ietf.org/html/rfc3339) timestamp format. + // Example: `2019-04-03T21:10:29.600Z` + TimeOfDeletion *common.SDKTime `mandatory:"false" json:"timeOfDeletion"` + + RevocationStatus *RevocationStatus `mandatory:"false" json:"revocationStatus"` +} + +func (m CertificateBundleVersionSummary) String() string { + return common.PointerString(m) +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (m CertificateBundleVersionSummary) ValidateEnumValue() (bool, error) { + errMessage := []string{} + for _, val := range m.Stages { + if _, ok := GetMappingVersionStageEnum(string(val)); !ok && val != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for Stages: %s. Supported values are: %s.", val, strings.Join(GetVersionStageEnumStringValues(), ","))) + } + } + + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_with_private_key.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_with_private_key.go new file mode 100644 index 00000000000..dba68197fb8 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificate_bundle_with_private_key.go @@ -0,0 +1,151 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "encoding/json" + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "strings" +) + +// CertificateBundleWithPrivateKey A certificate bundle, including the private key. +type CertificateBundleWithPrivateKey struct { + + // The OCID of the certificate. + CertificateId *string `mandatory:"true" json:"certificateId"` + + // The name of the certificate. + CertificateName *string `mandatory:"true" json:"certificateName"` + + // The version number of the certificate. + VersionNumber *int64 `mandatory:"true" json:"versionNumber"` + + // A unique certificate identifier used in certificate revocation tracking, formatted as octets. + // Example: `03 AC FC FA CC B3 CB 02 B8 F8 DE F5 85 E7 7B FF` + SerialNumber *string `mandatory:"true" json:"serialNumber"` + + // An optional property indicating when the certificate version was created, expressed in RFC 3339 (https://tools.ietf.org/html/rfc3339) timestamp format. + // Example: `2019-04-03T21:10:29.600Z` + TimeCreated *common.SDKTime `mandatory:"true" json:"timeCreated"` + + Validity *Validity `mandatory:"true" json:"validity"` + + // The private key (in PEM format) for the certificate. + PrivateKeyPem *string `mandatory:"true" json:"privateKeyPem"` + + // The certificate in PEM format. + CertificatePem *string `mandatory:"false" json:"certificatePem"` + + // The certificate chain (in PEM format) for the certificate bundle. + CertChainPem *string `mandatory:"false" json:"certChainPem"` + + // The name of the certificate version. + VersionName *string `mandatory:"false" json:"versionName"` + + RevocationStatus *RevocationStatus `mandatory:"false" json:"revocationStatus"` + + // An optional passphrase for the private key. + PrivateKeyPemPassphrase *string `mandatory:"false" json:"privateKeyPemPassphrase"` + + // A list of rotation states for the certificate bundle. + Stages []VersionStageEnum `mandatory:"true" json:"stages"` +} + +// GetCertificateId returns CertificateId +func (m CertificateBundleWithPrivateKey) GetCertificateId() *string { + return m.CertificateId +} + +// GetCertificateName returns CertificateName +func (m CertificateBundleWithPrivateKey) GetCertificateName() *string { + return m.CertificateName +} + +// GetVersionNumber returns VersionNumber +func (m CertificateBundleWithPrivateKey) GetVersionNumber() *int64 { + return m.VersionNumber +} + +// GetSerialNumber returns SerialNumber +func (m CertificateBundleWithPrivateKey) GetSerialNumber() *string { + return m.SerialNumber +} + +// GetCertificatePem returns CertificatePem +func (m CertificateBundleWithPrivateKey) GetCertificatePem() *string { + return m.CertificatePem +} + +// GetCertChainPem returns CertChainPem +func (m CertificateBundleWithPrivateKey) GetCertChainPem() *string { + return m.CertChainPem +} + +// GetTimeCreated returns TimeCreated +func (m CertificateBundleWithPrivateKey) GetTimeCreated() *common.SDKTime { + return m.TimeCreated +} + +// GetValidity returns Validity +func (m CertificateBundleWithPrivateKey) GetValidity() *Validity { + return m.Validity +} + +// GetVersionName returns VersionName +func (m CertificateBundleWithPrivateKey) GetVersionName() *string { + return m.VersionName +} + +// GetStages returns Stages +func (m CertificateBundleWithPrivateKey) GetStages() []VersionStageEnum { + return m.Stages +} + +// GetRevocationStatus returns RevocationStatus +func (m CertificateBundleWithPrivateKey) GetRevocationStatus() *RevocationStatus { + return m.RevocationStatus +} + +func (m CertificateBundleWithPrivateKey) String() string { + return common.PointerString(m) +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (m CertificateBundleWithPrivateKey) ValidateEnumValue() (bool, error) { + errMessage := []string{} + + for _, val := range m.Stages { + if _, ok := GetMappingVersionStageEnum(string(val)); !ok && val != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for Stages: %s. Supported values are: %s.", val, strings.Join(GetVersionStageEnumStringValues(), ","))) + } + } + + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} + +// MarshalJSON marshals to json representation +func (m CertificateBundleWithPrivateKey) MarshalJSON() (buff []byte, e error) { + type MarshalTypeCertificateBundleWithPrivateKey CertificateBundleWithPrivateKey + s := struct { + DiscriminatorParam string `json:"certificateBundleType"` + MarshalTypeCertificateBundleWithPrivateKey + }{ + "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY", + (MarshalTypeCertificateBundleWithPrivateKey)(m), + } + + return json.Marshal(&s) +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificates_client.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificates_client.go new file mode 100644 index 00000000000..a7f290397a3 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/certificates_client.go @@ -0,0 +1,381 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "context" + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "github.com/oracle/oci-go-sdk/v65/common/auth" + "net/http" +) + +// CertificatesClient a client for Certificates +type CertificatesClient struct { + common.BaseClient + config *common.ConfigurationProvider +} + +// NewCertificatesClientWithConfigurationProvider Creates a new default Certificates client with the given configuration provider. +// the configuration provider will be used for the default signer as well as reading the region +func NewCertificatesClientWithConfigurationProvider(configProvider common.ConfigurationProvider) (client CertificatesClient, err error) { + if enabled := common.CheckForEnabledServices("certificates"); !enabled { + return client, fmt.Errorf("the Developer Tool configuration disabled this service, this behavior is controlled by OciSdkEnabledServicesMap variables. Please check if your local developer-tool-configuration.json file configured the service you're targeting or contact the cloud provider on the availability of this service") + } + provider, err := auth.GetGenericConfigurationProvider(configProvider) + if err != nil { + return client, err + } + baseClient, e := common.NewClientWithConfig(provider) + if e != nil { + return client, e + } + return newCertificatesClientFromBaseClient(baseClient, provider) +} + +// NewCertificatesClientWithOboToken Creates a new default Certificates client with the given configuration provider. +// The obotoken will be added to default headers and signed; the configuration provider will be used for the signer +// +// as well as reading the region +func NewCertificatesClientWithOboToken(configProvider common.ConfigurationProvider, oboToken string) (client CertificatesClient, err error) { + baseClient, err := common.NewClientWithOboToken(configProvider, oboToken) + if err != nil { + return client, err + } + + return newCertificatesClientFromBaseClient(baseClient, configProvider) +} + +func newCertificatesClientFromBaseClient(baseClient common.BaseClient, configProvider common.ConfigurationProvider) (client CertificatesClient, err error) { + // Certificates service default circuit breaker is enabled + baseClient.Configuration.CircuitBreaker = common.NewCircuitBreaker(common.DefaultCircuitBreakerSettingWithServiceName("Certificates")) + common.ConfigCircuitBreakerFromEnvVar(&baseClient) + common.ConfigCircuitBreakerFromGlobalVar(&baseClient) + + client = CertificatesClient{BaseClient: baseClient} + client.BasePath = "20210224" + err = client.setConfigurationProvider(configProvider) + return +} + +// SetRegion overrides the region of this client. +func (client *CertificatesClient) SetRegion(region string) { + client.Host = common.StringToRegion(region).EndpointForTemplate("certificates", "https://certificates.{region}.oci.{secondLevelDomain}") +} + +// SetConfigurationProvider sets the configuration provider including the region, returns an error if is not valid +func (client *CertificatesClient) setConfigurationProvider(configProvider common.ConfigurationProvider) error { + if ok, err := common.IsConfigurationProviderValid(configProvider); !ok { + return err + } + + // Error has been checked already + region, _ := configProvider.Region() + client.SetRegion(region) + if client.Host == "" { + return fmt.Errorf("invalid region or Host. Endpoint cannot be constructed without endpointServiceName or serviceEndpointTemplate for a dotted region") + } + client.config = &configProvider + return nil +} + +// ConfigurationProvider the ConfigurationProvider used in this client, or null if none set +func (client *CertificatesClient) ConfigurationProvider() *common.ConfigurationProvider { + return client.config +} + +// GetCaBundle Gets a ca-bundle bundle. +// +// # See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/certificates/GetCaBundle.go.html to see an example of how to use GetCaBundle API. +func (client CertificatesClient) GetCaBundle(ctx context.Context, request GetCaBundleRequest) (response GetCaBundleResponse, err error) { + var ociResponse common.OCIResponse + policy := common.NoRetryPolicy() + if client.RetryPolicy() != nil { + policy = *client.RetryPolicy() + } + if request.RetryPolicy() != nil { + policy = *request.RetryPolicy() + } + ociResponse, err = common.Retry(ctx, request, client.getCaBundle, policy) + if err != nil { + if ociResponse != nil { + if httpResponse := ociResponse.HTTPResponse(); httpResponse != nil { + opcRequestId := httpResponse.Header.Get("opc-request-id") + response = GetCaBundleResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId} + } else { + response = GetCaBundleResponse{} + } + } + return + } + if convertedResponse, ok := ociResponse.(GetCaBundleResponse); ok { + response = convertedResponse + } else { + err = fmt.Errorf("failed to convert OCIResponse into GetCaBundleResponse") + } + return +} + +// getCaBundle implements the OCIOperation interface (enables retrying operations) +func (client CertificatesClient) getCaBundle(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodGet, "/caBundles/{caBundleId}", binaryReqBody, extraHeaders) + if err != nil { + return nil, err + } + + var response GetCaBundleResponse + var httpResponse *http.Response + httpResponse, err = client.Call(ctx, &httpRequest) + defer common.CloseBodyIfValid(httpResponse) + response.RawResponse = httpResponse + if err != nil { + apiReferenceLink := "https://docs.oracle.com/iaas/api/#/en/certificates/20210224/CaBundle/GetCaBundle" + err = common.PostProcessServiceError(err, "Certificates", "GetCaBundle", apiReferenceLink) + return response, err + } + + err = common.UnmarshalResponse(httpResponse, &response) + return response, err +} + +// GetCertificateAuthorityBundle Gets a certificate authority bundle that matches either the specified `stage`, `name`, or `versionNumber` parameter. +// If none of these parameters are provided, the bundle for the certificate authority version marked as `CURRENT` will be returned. +// +// # See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/certificates/GetCertificateAuthorityBundle.go.html to see an example of how to use GetCertificateAuthorityBundle API. +func (client CertificatesClient) GetCertificateAuthorityBundle(ctx context.Context, request GetCertificateAuthorityBundleRequest) (response GetCertificateAuthorityBundleResponse, err error) { + var ociResponse common.OCIResponse + policy := common.NoRetryPolicy() + if client.RetryPolicy() != nil { + policy = *client.RetryPolicy() + } + if request.RetryPolicy() != nil { + policy = *request.RetryPolicy() + } + ociResponse, err = common.Retry(ctx, request, client.getCertificateAuthorityBundle, policy) + if err != nil { + if ociResponse != nil { + if httpResponse := ociResponse.HTTPResponse(); httpResponse != nil { + opcRequestId := httpResponse.Header.Get("opc-request-id") + response = GetCertificateAuthorityBundleResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId} + } else { + response = GetCertificateAuthorityBundleResponse{} + } + } + return + } + if convertedResponse, ok := ociResponse.(GetCertificateAuthorityBundleResponse); ok { + response = convertedResponse + } else { + err = fmt.Errorf("failed to convert OCIResponse into GetCertificateAuthorityBundleResponse") + } + return +} + +// getCertificateAuthorityBundle implements the OCIOperation interface (enables retrying operations) +func (client CertificatesClient) getCertificateAuthorityBundle(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodGet, "/certificateAuthorityBundles/{certificateAuthorityId}", binaryReqBody, extraHeaders) + if err != nil { + return nil, err + } + + var response GetCertificateAuthorityBundleResponse + var httpResponse *http.Response + httpResponse, err = client.Call(ctx, &httpRequest) + defer common.CloseBodyIfValid(httpResponse) + response.RawResponse = httpResponse + if err != nil { + apiReferenceLink := "https://docs.oracle.com/iaas/api/#/en/certificates/20210224/CertificateAuthorityBundle/GetCertificateAuthorityBundle" + err = common.PostProcessServiceError(err, "Certificates", "GetCertificateAuthorityBundle", apiReferenceLink) + return response, err + } + + err = common.UnmarshalResponse(httpResponse, &response) + return response, err +} + +// GetCertificateBundle Gets a certificate bundle that matches either the specified `stage`, `versionName`, or `versionNumber` parameter. +// If none of these parameters are provided, the bundle for the certificate version marked as `CURRENT` will be returned. +// By default, the private key is not included in the query result, and a CertificateBundlePublicOnly is returned. +// If the private key is needed, use the CertificateBundleTypeQueryParam parameter to get a CertificateBundleWithPrivateKey response. +// +// # See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/certificates/GetCertificateBundle.go.html to see an example of how to use GetCertificateBundle API. +func (client CertificatesClient) GetCertificateBundle(ctx context.Context, request GetCertificateBundleRequest) (response GetCertificateBundleResponse, err error) { + var ociResponse common.OCIResponse + policy := common.NoRetryPolicy() + if client.RetryPolicy() != nil { + policy = *client.RetryPolicy() + } + if request.RetryPolicy() != nil { + policy = *request.RetryPolicy() + } + ociResponse, err = common.Retry(ctx, request, client.getCertificateBundle, policy) + if err != nil { + if ociResponse != nil { + if httpResponse := ociResponse.HTTPResponse(); httpResponse != nil { + opcRequestId := httpResponse.Header.Get("opc-request-id") + response = GetCertificateBundleResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId} + } else { + response = GetCertificateBundleResponse{} + } + } + return + } + if convertedResponse, ok := ociResponse.(GetCertificateBundleResponse); ok { + response = convertedResponse + } else { + err = fmt.Errorf("failed to convert OCIResponse into GetCertificateBundleResponse") + } + return +} + +// getCertificateBundle implements the OCIOperation interface (enables retrying operations) +func (client CertificatesClient) getCertificateBundle(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodGet, "/certificateBundles/{certificateId}", binaryReqBody, extraHeaders) + if err != nil { + return nil, err + } + + var response GetCertificateBundleResponse + var httpResponse *http.Response + httpResponse, err = client.Call(ctx, &httpRequest) + defer common.CloseBodyIfValid(httpResponse) + response.RawResponse = httpResponse + if err != nil { + apiReferenceLink := "https://docs.oracle.com/iaas/api/#/en/certificates/20210224/CertificateBundle/GetCertificateBundle" + err = common.PostProcessServiceError(err, "Certificates", "GetCertificateBundle", apiReferenceLink) + return response, err + } + + err = common.UnmarshalResponseWithPolymorphicBody(httpResponse, &response, &certificatebundle{}) + return response, err +} + +// ListCertificateAuthorityBundleVersions Lists all certificate authority bundle versions for the specified certificate authority. +// +// # See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/certificates/ListCertificateAuthorityBundleVersions.go.html to see an example of how to use ListCertificateAuthorityBundleVersions API. +func (client CertificatesClient) ListCertificateAuthorityBundleVersions(ctx context.Context, request ListCertificateAuthorityBundleVersionsRequest) (response ListCertificateAuthorityBundleVersionsResponse, err error) { + var ociResponse common.OCIResponse + policy := common.NoRetryPolicy() + if client.RetryPolicy() != nil { + policy = *client.RetryPolicy() + } + if request.RetryPolicy() != nil { + policy = *request.RetryPolicy() + } + ociResponse, err = common.Retry(ctx, request, client.listCertificateAuthorityBundleVersions, policy) + if err != nil { + if ociResponse != nil { + if httpResponse := ociResponse.HTTPResponse(); httpResponse != nil { + opcRequestId := httpResponse.Header.Get("opc-request-id") + response = ListCertificateAuthorityBundleVersionsResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId} + } else { + response = ListCertificateAuthorityBundleVersionsResponse{} + } + } + return + } + if convertedResponse, ok := ociResponse.(ListCertificateAuthorityBundleVersionsResponse); ok { + response = convertedResponse + } else { + err = fmt.Errorf("failed to convert OCIResponse into ListCertificateAuthorityBundleVersionsResponse") + } + return +} + +// listCertificateAuthorityBundleVersions implements the OCIOperation interface (enables retrying operations) +func (client CertificatesClient) listCertificateAuthorityBundleVersions(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodGet, "/certificateAuthorityBundles/{certificateAuthorityId}/versions", binaryReqBody, extraHeaders) + if err != nil { + return nil, err + } + + var response ListCertificateAuthorityBundleVersionsResponse + var httpResponse *http.Response + httpResponse, err = client.Call(ctx, &httpRequest) + defer common.CloseBodyIfValid(httpResponse) + response.RawResponse = httpResponse + if err != nil { + apiReferenceLink := "https://docs.oracle.com/iaas/api/#/en/certificates/20210224/CertificateAuthorityBundleVersionSummary/ListCertificateAuthorityBundleVersions" + err = common.PostProcessServiceError(err, "Certificates", "ListCertificateAuthorityBundleVersions", apiReferenceLink) + return response, err + } + + err = common.UnmarshalResponse(httpResponse, &response) + return response, err +} + +// ListCertificateBundleVersions Lists all certificate bundle versions for the specified certificate. +// +// # See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/certificates/ListCertificateBundleVersions.go.html to see an example of how to use ListCertificateBundleVersions API. +func (client CertificatesClient) ListCertificateBundleVersions(ctx context.Context, request ListCertificateBundleVersionsRequest) (response ListCertificateBundleVersionsResponse, err error) { + var ociResponse common.OCIResponse + policy := common.NoRetryPolicy() + if client.RetryPolicy() != nil { + policy = *client.RetryPolicy() + } + if request.RetryPolicy() != nil { + policy = *request.RetryPolicy() + } + ociResponse, err = common.Retry(ctx, request, client.listCertificateBundleVersions, policy) + if err != nil { + if ociResponse != nil { + if httpResponse := ociResponse.HTTPResponse(); httpResponse != nil { + opcRequestId := httpResponse.Header.Get("opc-request-id") + response = ListCertificateBundleVersionsResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId} + } else { + response = ListCertificateBundleVersionsResponse{} + } + } + return + } + if convertedResponse, ok := ociResponse.(ListCertificateBundleVersionsResponse); ok { + response = convertedResponse + } else { + err = fmt.Errorf("failed to convert OCIResponse into ListCertificateBundleVersionsResponse") + } + return +} + +// listCertificateBundleVersions implements the OCIOperation interface (enables retrying operations) +func (client CertificatesClient) listCertificateBundleVersions(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodGet, "/certificateBundles/{certificateId}/versions", binaryReqBody, extraHeaders) + if err != nil { + return nil, err + } + + var response ListCertificateBundleVersionsResponse + var httpResponse *http.Response + httpResponse, err = client.Call(ctx, &httpRequest) + defer common.CloseBodyIfValid(httpResponse) + response.RawResponse = httpResponse + if err != nil { + apiReferenceLink := "https://docs.oracle.com/iaas/api/#/en/certificates/20210224/CertificateBundleVersionSummary/ListCertificateBundleVersions" + err = common.PostProcessServiceError(err, "Certificates", "ListCertificateBundleVersions", apiReferenceLink) + return response, err + } + + err = common.UnmarshalResponse(httpResponse, &response) + return response, err +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_ca_bundle_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_ca_bundle_request_response.go new file mode 100644 index 00000000000..d8143c6a6c1 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_ca_bundle_request_response.go @@ -0,0 +1,93 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "net/http" + "strings" +) + +// GetCaBundleRequest wrapper for the GetCaBundle operation +// +// # See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/certificates/GetCaBundle.go.html to see an example of how to use GetCaBundleRequest. +type GetCaBundleRequest struct { + + // The OCID of the CA bundle. + CaBundleId *string `mandatory:"true" contributesTo:"path" name:"caBundleId"` + + // Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, + // please provide the request ID. + OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"` + + // Metadata about the request. This information will not be transmitted to the service, but + // represents information that the SDK will consume to drive retry behavior. + RequestMetadata common.RequestMetadata +} + +func (request GetCaBundleRequest) String() string { + return common.PointerString(request) +} + +// HTTPRequest implements the OCIRequest interface +func (request GetCaBundleRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + _, err := request.ValidateEnumValue() + if err != nil { + return http.Request{}, err + } + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request GetCaBundleRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + +} + +// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. +func (request GetCaBundleRequest) RetryPolicy() *common.RetryPolicy { + return request.RequestMetadata.RetryPolicy +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (request GetCaBundleRequest) ValidateEnumValue() (bool, error) { + errMessage := []string{} + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} + +// GetCaBundleResponse wrapper for the GetCaBundle operation +type GetCaBundleResponse struct { + + // The underlying http response + RawResponse *http.Response + + // The CaBundle instance + CaBundle `presentIn:"body"` + + // For optimistic concurrency control. See `if-match`. + Etag *string `presentIn:"header" name:"etag"` + + // Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID. + OpcRequestId *string `presentIn:"header" name:"opc-request-id"` +} + +func (response GetCaBundleResponse) String() string { + return common.PointerString(response) +} + +// HTTPResponse implements the OCIResponse interface +func (response GetCaBundleResponse) HTTPResponse() *http.Response { + return response.RawResponse +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_certificate_authority_bundle_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_certificate_authority_bundle_request_response.go new file mode 100644 index 00000000000..0ec3ede49e3 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_certificate_authority_bundle_request_response.go @@ -0,0 +1,159 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "net/http" + "strings" +) + +// GetCertificateAuthorityBundleRequest wrapper for the GetCertificateAuthorityBundle operation +// +// # See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/certificates/GetCertificateAuthorityBundle.go.html to see an example of how to use GetCertificateAuthorityBundleRequest. +type GetCertificateAuthorityBundleRequest struct { + + // The OCID of the certificate authority (CA). + CertificateAuthorityId *string `mandatory:"true" contributesTo:"path" name:"certificateAuthorityId"` + + // Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, + // please provide the request ID. + OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"` + + // The version number of the certificate authority (CA). + VersionNumber *int64 `mandatory:"false" contributesTo:"query" name:"versionNumber"` + + // The name of the certificate authority (CA). (This might be referred to as the name of the CA version, as every CA consists of at least one version.) Names are unique across versions of a given CA. + CertificateAuthorityVersionName *string `mandatory:"false" contributesTo:"query" name:"certificateAuthorityVersionName"` + + // The rotation state of the certificate version. + Stage GetCertificateAuthorityBundleStageEnum `mandatory:"false" contributesTo:"query" name:"stage" omitEmpty:"true"` + + // Metadata about the request. This information will not be transmitted to the service, but + // represents information that the SDK will consume to drive retry behavior. + RequestMetadata common.RequestMetadata +} + +func (request GetCertificateAuthorityBundleRequest) String() string { + return common.PointerString(request) +} + +// HTTPRequest implements the OCIRequest interface +func (request GetCertificateAuthorityBundleRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + _, err := request.ValidateEnumValue() + if err != nil { + return http.Request{}, err + } + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request GetCertificateAuthorityBundleRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + +} + +// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. +func (request GetCertificateAuthorityBundleRequest) RetryPolicy() *common.RetryPolicy { + return request.RequestMetadata.RetryPolicy +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (request GetCertificateAuthorityBundleRequest) ValidateEnumValue() (bool, error) { + errMessage := []string{} + if _, ok := GetMappingGetCertificateAuthorityBundleStageEnum(string(request.Stage)); !ok && request.Stage != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for Stage: %s. Supported values are: %s.", request.Stage, strings.Join(GetGetCertificateAuthorityBundleStageEnumStringValues(), ","))) + } + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} + +// GetCertificateAuthorityBundleResponse wrapper for the GetCertificateAuthorityBundle operation +type GetCertificateAuthorityBundleResponse struct { + + // The underlying http response + RawResponse *http.Response + + // The CertificateAuthorityBundle instance + CertificateAuthorityBundle `presentIn:"body"` + + // For optimistic concurrency control. See `if-match`. + Etag *string `presentIn:"header" name:"etag"` + + // Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID. + OpcRequestId *string `presentIn:"header" name:"opc-request-id"` +} + +func (response GetCertificateAuthorityBundleResponse) String() string { + return common.PointerString(response) +} + +// HTTPResponse implements the OCIResponse interface +func (response GetCertificateAuthorityBundleResponse) HTTPResponse() *http.Response { + return response.RawResponse +} + +// GetCertificateAuthorityBundleStageEnum Enum with underlying type: string +type GetCertificateAuthorityBundleStageEnum string + +// Set of constants representing the allowable values for GetCertificateAuthorityBundleStageEnum +const ( + GetCertificateAuthorityBundleStageCurrent GetCertificateAuthorityBundleStageEnum = "CURRENT" + GetCertificateAuthorityBundleStagePending GetCertificateAuthorityBundleStageEnum = "PENDING" + GetCertificateAuthorityBundleStageLatest GetCertificateAuthorityBundleStageEnum = "LATEST" + GetCertificateAuthorityBundleStagePrevious GetCertificateAuthorityBundleStageEnum = "PREVIOUS" + GetCertificateAuthorityBundleStageDeprecated GetCertificateAuthorityBundleStageEnum = "DEPRECATED" +) + +var mappingGetCertificateAuthorityBundleStageEnum = map[string]GetCertificateAuthorityBundleStageEnum{ + "CURRENT": GetCertificateAuthorityBundleStageCurrent, + "PENDING": GetCertificateAuthorityBundleStagePending, + "LATEST": GetCertificateAuthorityBundleStageLatest, + "PREVIOUS": GetCertificateAuthorityBundleStagePrevious, + "DEPRECATED": GetCertificateAuthorityBundleStageDeprecated, +} + +var mappingGetCertificateAuthorityBundleStageEnumLowerCase = map[string]GetCertificateAuthorityBundleStageEnum{ + "current": GetCertificateAuthorityBundleStageCurrent, + "pending": GetCertificateAuthorityBundleStagePending, + "latest": GetCertificateAuthorityBundleStageLatest, + "previous": GetCertificateAuthorityBundleStagePrevious, + "deprecated": GetCertificateAuthorityBundleStageDeprecated, +} + +// GetGetCertificateAuthorityBundleStageEnumValues Enumerates the set of values for GetCertificateAuthorityBundleStageEnum +func GetGetCertificateAuthorityBundleStageEnumValues() []GetCertificateAuthorityBundleStageEnum { + values := make([]GetCertificateAuthorityBundleStageEnum, 0) + for _, v := range mappingGetCertificateAuthorityBundleStageEnum { + values = append(values, v) + } + return values +} + +// GetGetCertificateAuthorityBundleStageEnumStringValues Enumerates the set of values in String for GetCertificateAuthorityBundleStageEnum +func GetGetCertificateAuthorityBundleStageEnumStringValues() []string { + return []string{ + "CURRENT", + "PENDING", + "LATEST", + "PREVIOUS", + "DEPRECATED", + } +} + +// GetMappingGetCertificateAuthorityBundleStageEnum performs case Insensitive comparison on enum value and return the desired enum +func GetMappingGetCertificateAuthorityBundleStageEnum(val string) (GetCertificateAuthorityBundleStageEnum, bool) { + enum, ok := mappingGetCertificateAuthorityBundleStageEnumLowerCase[strings.ToLower(val)] + return enum, ok +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_certificate_bundle_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_certificate_bundle_request_response.go new file mode 100644 index 00000000000..80b02130431 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/get_certificate_bundle_request_response.go @@ -0,0 +1,207 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "net/http" + "strings" +) + +// GetCertificateBundleRequest wrapper for the GetCertificateBundle operation +// +// # See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/certificates/GetCertificateBundle.go.html to see an example of how to use GetCertificateBundleRequest. +type GetCertificateBundleRequest struct { + + // The OCID of the certificate. + CertificateId *string `mandatory:"true" contributesTo:"path" name:"certificateId"` + + // Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, + // please provide the request ID. + OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"` + + // The version number of the certificate. The default value is 0, which means that this query parameter is ignored. + VersionNumber *int64 `mandatory:"false" contributesTo:"query" name:"versionNumber"` + + // The name of the certificate. (This might be referred to as the name of the certificate version, as every certificate consists of at least one version.) Names are unique across versions of a given certificate. + CertificateVersionName *string `mandatory:"false" contributesTo:"query" name:"certificateVersionName"` + + // The rotation state of the certificate version. + Stage GetCertificateBundleStageEnum `mandatory:"false" contributesTo:"query" name:"stage" omitEmpty:"true"` + + // The type of certificate bundle. By default, the private key fields are not returned. When querying for certificate bundles, to return results with certificate contents, the private key in PEM format, and the private key passphrase, specify the value of this parameter as `CERTIFICATE_CONTENT_WITH_PRIVATE_KEY`. + CertificateBundleType GetCertificateBundleCertificateBundleTypeEnum `mandatory:"false" contributesTo:"query" name:"certificateBundleType" omitEmpty:"true"` + + // Metadata about the request. This information will not be transmitted to the service, but + // represents information that the SDK will consume to drive retry behavior. + RequestMetadata common.RequestMetadata +} + +func (request GetCertificateBundleRequest) String() string { + return common.PointerString(request) +} + +// HTTPRequest implements the OCIRequest interface +func (request GetCertificateBundleRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + _, err := request.ValidateEnumValue() + if err != nil { + return http.Request{}, err + } + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request GetCertificateBundleRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + +} + +// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. +func (request GetCertificateBundleRequest) RetryPolicy() *common.RetryPolicy { + return request.RequestMetadata.RetryPolicy +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (request GetCertificateBundleRequest) ValidateEnumValue() (bool, error) { + errMessage := []string{} + if _, ok := GetMappingGetCertificateBundleStageEnum(string(request.Stage)); !ok && request.Stage != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for Stage: %s. Supported values are: %s.", request.Stage, strings.Join(GetGetCertificateBundleStageEnumStringValues(), ","))) + } + if _, ok := GetMappingGetCertificateBundleCertificateBundleTypeEnum(string(request.CertificateBundleType)); !ok && request.CertificateBundleType != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for CertificateBundleType: %s. Supported values are: %s.", request.CertificateBundleType, strings.Join(GetGetCertificateBundleCertificateBundleTypeEnumStringValues(), ","))) + } + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} + +// GetCertificateBundleResponse wrapper for the GetCertificateBundle operation +type GetCertificateBundleResponse struct { + + // The underlying http response + RawResponse *http.Response + + // The CertificateBundle instance + CertificateBundle `presentIn:"body"` + + // For optimistic concurrency control. See `if-match`. + Etag *string `presentIn:"header" name:"etag"` + + // Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID. + OpcRequestId *string `presentIn:"header" name:"opc-request-id"` +} + +func (response GetCertificateBundleResponse) String() string { + return common.PointerString(response) +} + +// HTTPResponse implements the OCIResponse interface +func (response GetCertificateBundleResponse) HTTPResponse() *http.Response { + return response.RawResponse +} + +// GetCertificateBundleStageEnum Enum with underlying type: string +type GetCertificateBundleStageEnum string + +// Set of constants representing the allowable values for GetCertificateBundleStageEnum +const ( + GetCertificateBundleStageCurrent GetCertificateBundleStageEnum = "CURRENT" + GetCertificateBundleStagePending GetCertificateBundleStageEnum = "PENDING" + GetCertificateBundleStageLatest GetCertificateBundleStageEnum = "LATEST" + GetCertificateBundleStagePrevious GetCertificateBundleStageEnum = "PREVIOUS" + GetCertificateBundleStageDeprecated GetCertificateBundleStageEnum = "DEPRECATED" +) + +var mappingGetCertificateBundleStageEnum = map[string]GetCertificateBundleStageEnum{ + "CURRENT": GetCertificateBundleStageCurrent, + "PENDING": GetCertificateBundleStagePending, + "LATEST": GetCertificateBundleStageLatest, + "PREVIOUS": GetCertificateBundleStagePrevious, + "DEPRECATED": GetCertificateBundleStageDeprecated, +} + +var mappingGetCertificateBundleStageEnumLowerCase = map[string]GetCertificateBundleStageEnum{ + "current": GetCertificateBundleStageCurrent, + "pending": GetCertificateBundleStagePending, + "latest": GetCertificateBundleStageLatest, + "previous": GetCertificateBundleStagePrevious, + "deprecated": GetCertificateBundleStageDeprecated, +} + +// GetGetCertificateBundleStageEnumValues Enumerates the set of values for GetCertificateBundleStageEnum +func GetGetCertificateBundleStageEnumValues() []GetCertificateBundleStageEnum { + values := make([]GetCertificateBundleStageEnum, 0) + for _, v := range mappingGetCertificateBundleStageEnum { + values = append(values, v) + } + return values +} + +// GetGetCertificateBundleStageEnumStringValues Enumerates the set of values in String for GetCertificateBundleStageEnum +func GetGetCertificateBundleStageEnumStringValues() []string { + return []string{ + "CURRENT", + "PENDING", + "LATEST", + "PREVIOUS", + "DEPRECATED", + } +} + +// GetMappingGetCertificateBundleStageEnum performs case Insensitive comparison on enum value and return the desired enum +func GetMappingGetCertificateBundleStageEnum(val string) (GetCertificateBundleStageEnum, bool) { + enum, ok := mappingGetCertificateBundleStageEnumLowerCase[strings.ToLower(val)] + return enum, ok +} + +// GetCertificateBundleCertificateBundleTypeEnum Enum with underlying type: string +type GetCertificateBundleCertificateBundleTypeEnum string + +// Set of constants representing the allowable values for GetCertificateBundleCertificateBundleTypeEnum +const ( + GetCertificateBundleCertificateBundleTypePublicOnly GetCertificateBundleCertificateBundleTypeEnum = "CERTIFICATE_CONTENT_PUBLIC_ONLY" + GetCertificateBundleCertificateBundleTypeWithPrivateKey GetCertificateBundleCertificateBundleTypeEnum = "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY" +) + +var mappingGetCertificateBundleCertificateBundleTypeEnum = map[string]GetCertificateBundleCertificateBundleTypeEnum{ + "CERTIFICATE_CONTENT_PUBLIC_ONLY": GetCertificateBundleCertificateBundleTypePublicOnly, + "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY": GetCertificateBundleCertificateBundleTypeWithPrivateKey, +} + +var mappingGetCertificateBundleCertificateBundleTypeEnumLowerCase = map[string]GetCertificateBundleCertificateBundleTypeEnum{ + "certificate_content_public_only": GetCertificateBundleCertificateBundleTypePublicOnly, + "certificate_content_with_private_key": GetCertificateBundleCertificateBundleTypeWithPrivateKey, +} + +// GetGetCertificateBundleCertificateBundleTypeEnumValues Enumerates the set of values for GetCertificateBundleCertificateBundleTypeEnum +func GetGetCertificateBundleCertificateBundleTypeEnumValues() []GetCertificateBundleCertificateBundleTypeEnum { + values := make([]GetCertificateBundleCertificateBundleTypeEnum, 0) + for _, v := range mappingGetCertificateBundleCertificateBundleTypeEnum { + values = append(values, v) + } + return values +} + +// GetGetCertificateBundleCertificateBundleTypeEnumStringValues Enumerates the set of values in String for GetCertificateBundleCertificateBundleTypeEnum +func GetGetCertificateBundleCertificateBundleTypeEnumStringValues() []string { + return []string{ + "CERTIFICATE_CONTENT_PUBLIC_ONLY", + "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY", + } +} + +// GetMappingGetCertificateBundleCertificateBundleTypeEnum performs case Insensitive comparison on enum value and return the desired enum +func GetMappingGetCertificateBundleCertificateBundleTypeEnum(val string) (GetCertificateBundleCertificateBundleTypeEnum, bool) { + enum, ok := mappingGetCertificateBundleCertificateBundleTypeEnumLowerCase[strings.ToLower(val)] + return enum, ok +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/list_certificate_authority_bundle_versions_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/list_certificate_authority_bundle_versions_request_response.go new file mode 100644 index 00000000000..458dc9f74d9 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/list_certificate_authority_bundle_versions_request_response.go @@ -0,0 +1,183 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "net/http" + "strings" +) + +// ListCertificateAuthorityBundleVersionsRequest wrapper for the ListCertificateAuthorityBundleVersions operation +// +// # See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/certificates/ListCertificateAuthorityBundleVersions.go.html to see an example of how to use ListCertificateAuthorityBundleVersionsRequest. +type ListCertificateAuthorityBundleVersionsRequest struct { + + // The OCID of the certificate authority (CA). + CertificateAuthorityId *string `mandatory:"true" contributesTo:"path" name:"certificateAuthorityId"` + + // Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, + // please provide the request ID. + OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"` + + // The field to sort by. You can specify only one sort order. The default + // order for `VERSION_NUMBER` is ascending. + SortBy ListCertificateAuthorityBundleVersionsSortByEnum `mandatory:"false" contributesTo:"query" name:"sortBy" omitEmpty:"true"` + + // The sort order to use, either ascending (`ASC`) or descending (`DESC`). + SortOrder ListCertificateAuthorityBundleVersionsSortOrderEnum `mandatory:"false" contributesTo:"query" name:"sortOrder" omitEmpty:"true"` + + // Metadata about the request. This information will not be transmitted to the service, but + // represents information that the SDK will consume to drive retry behavior. + RequestMetadata common.RequestMetadata +} + +func (request ListCertificateAuthorityBundleVersionsRequest) String() string { + return common.PointerString(request) +} + +// HTTPRequest implements the OCIRequest interface +func (request ListCertificateAuthorityBundleVersionsRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + _, err := request.ValidateEnumValue() + if err != nil { + return http.Request{}, err + } + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request ListCertificateAuthorityBundleVersionsRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + +} + +// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. +func (request ListCertificateAuthorityBundleVersionsRequest) RetryPolicy() *common.RetryPolicy { + return request.RequestMetadata.RetryPolicy +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (request ListCertificateAuthorityBundleVersionsRequest) ValidateEnumValue() (bool, error) { + errMessage := []string{} + if _, ok := GetMappingListCertificateAuthorityBundleVersionsSortByEnum(string(request.SortBy)); !ok && request.SortBy != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for SortBy: %s. Supported values are: %s.", request.SortBy, strings.Join(GetListCertificateAuthorityBundleVersionsSortByEnumStringValues(), ","))) + } + if _, ok := GetMappingListCertificateAuthorityBundleVersionsSortOrderEnum(string(request.SortOrder)); !ok && request.SortOrder != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for SortOrder: %s. Supported values are: %s.", request.SortOrder, strings.Join(GetListCertificateAuthorityBundleVersionsSortOrderEnumStringValues(), ","))) + } + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} + +// ListCertificateAuthorityBundleVersionsResponse wrapper for the ListCertificateAuthorityBundleVersions operation +type ListCertificateAuthorityBundleVersionsResponse struct { + + // The underlying http response + RawResponse *http.Response + + // The CertificateAuthorityBundleVersionCollection instance + CertificateAuthorityBundleVersionCollection `presentIn:"body"` + + // Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID. + OpcRequestId *string `presentIn:"header" name:"opc-request-id"` +} + +func (response ListCertificateAuthorityBundleVersionsResponse) String() string { + return common.PointerString(response) +} + +// HTTPResponse implements the OCIResponse interface +func (response ListCertificateAuthorityBundleVersionsResponse) HTTPResponse() *http.Response { + return response.RawResponse +} + +// ListCertificateAuthorityBundleVersionsSortByEnum Enum with underlying type: string +type ListCertificateAuthorityBundleVersionsSortByEnum string + +// Set of constants representing the allowable values for ListCertificateAuthorityBundleVersionsSortByEnum +const ( + ListCertificateAuthorityBundleVersionsSortByVersionNumber ListCertificateAuthorityBundleVersionsSortByEnum = "VERSION_NUMBER" +) + +var mappingListCertificateAuthorityBundleVersionsSortByEnum = map[string]ListCertificateAuthorityBundleVersionsSortByEnum{ + "VERSION_NUMBER": ListCertificateAuthorityBundleVersionsSortByVersionNumber, +} + +var mappingListCertificateAuthorityBundleVersionsSortByEnumLowerCase = map[string]ListCertificateAuthorityBundleVersionsSortByEnum{ + "version_number": ListCertificateAuthorityBundleVersionsSortByVersionNumber, +} + +// GetListCertificateAuthorityBundleVersionsSortByEnumValues Enumerates the set of values for ListCertificateAuthorityBundleVersionsSortByEnum +func GetListCertificateAuthorityBundleVersionsSortByEnumValues() []ListCertificateAuthorityBundleVersionsSortByEnum { + values := make([]ListCertificateAuthorityBundleVersionsSortByEnum, 0) + for _, v := range mappingListCertificateAuthorityBundleVersionsSortByEnum { + values = append(values, v) + } + return values +} + +// GetListCertificateAuthorityBundleVersionsSortByEnumStringValues Enumerates the set of values in String for ListCertificateAuthorityBundleVersionsSortByEnum +func GetListCertificateAuthorityBundleVersionsSortByEnumStringValues() []string { + return []string{ + "VERSION_NUMBER", + } +} + +// GetMappingListCertificateAuthorityBundleVersionsSortByEnum performs case Insensitive comparison on enum value and return the desired enum +func GetMappingListCertificateAuthorityBundleVersionsSortByEnum(val string) (ListCertificateAuthorityBundleVersionsSortByEnum, bool) { + enum, ok := mappingListCertificateAuthorityBundleVersionsSortByEnumLowerCase[strings.ToLower(val)] + return enum, ok +} + +// ListCertificateAuthorityBundleVersionsSortOrderEnum Enum with underlying type: string +type ListCertificateAuthorityBundleVersionsSortOrderEnum string + +// Set of constants representing the allowable values for ListCertificateAuthorityBundleVersionsSortOrderEnum +const ( + ListCertificateAuthorityBundleVersionsSortOrderAsc ListCertificateAuthorityBundleVersionsSortOrderEnum = "ASC" + ListCertificateAuthorityBundleVersionsSortOrderDesc ListCertificateAuthorityBundleVersionsSortOrderEnum = "DESC" +) + +var mappingListCertificateAuthorityBundleVersionsSortOrderEnum = map[string]ListCertificateAuthorityBundleVersionsSortOrderEnum{ + "ASC": ListCertificateAuthorityBundleVersionsSortOrderAsc, + "DESC": ListCertificateAuthorityBundleVersionsSortOrderDesc, +} + +var mappingListCertificateAuthorityBundleVersionsSortOrderEnumLowerCase = map[string]ListCertificateAuthorityBundleVersionsSortOrderEnum{ + "asc": ListCertificateAuthorityBundleVersionsSortOrderAsc, + "desc": ListCertificateAuthorityBundleVersionsSortOrderDesc, +} + +// GetListCertificateAuthorityBundleVersionsSortOrderEnumValues Enumerates the set of values for ListCertificateAuthorityBundleVersionsSortOrderEnum +func GetListCertificateAuthorityBundleVersionsSortOrderEnumValues() []ListCertificateAuthorityBundleVersionsSortOrderEnum { + values := make([]ListCertificateAuthorityBundleVersionsSortOrderEnum, 0) + for _, v := range mappingListCertificateAuthorityBundleVersionsSortOrderEnum { + values = append(values, v) + } + return values +} + +// GetListCertificateAuthorityBundleVersionsSortOrderEnumStringValues Enumerates the set of values in String for ListCertificateAuthorityBundleVersionsSortOrderEnum +func GetListCertificateAuthorityBundleVersionsSortOrderEnumStringValues() []string { + return []string{ + "ASC", + "DESC", + } +} + +// GetMappingListCertificateAuthorityBundleVersionsSortOrderEnum performs case Insensitive comparison on enum value and return the desired enum +func GetMappingListCertificateAuthorityBundleVersionsSortOrderEnum(val string) (ListCertificateAuthorityBundleVersionsSortOrderEnum, bool) { + enum, ok := mappingListCertificateAuthorityBundleVersionsSortOrderEnumLowerCase[strings.ToLower(val)] + return enum, ok +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/list_certificate_bundle_versions_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/list_certificate_bundle_versions_request_response.go new file mode 100644 index 00000000000..dca3618192e --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/list_certificate_bundle_versions_request_response.go @@ -0,0 +1,183 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "net/http" + "strings" +) + +// ListCertificateBundleVersionsRequest wrapper for the ListCertificateBundleVersions operation +// +// # See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/certificates/ListCertificateBundleVersions.go.html to see an example of how to use ListCertificateBundleVersionsRequest. +type ListCertificateBundleVersionsRequest struct { + + // The OCID of the certificate. + CertificateId *string `mandatory:"true" contributesTo:"path" name:"certificateId"` + + // Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, + // please provide the request ID. + OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"` + + // The field to sort by. You can specify only one sort order. The default + // order for `VERSION_NUMBER` is ascending. + SortBy ListCertificateBundleVersionsSortByEnum `mandatory:"false" contributesTo:"query" name:"sortBy" omitEmpty:"true"` + + // The sort order to use, either ascending (`ASC`) or descending (`DESC`). + SortOrder ListCertificateBundleVersionsSortOrderEnum `mandatory:"false" contributesTo:"query" name:"sortOrder" omitEmpty:"true"` + + // Metadata about the request. This information will not be transmitted to the service, but + // represents information that the SDK will consume to drive retry behavior. + RequestMetadata common.RequestMetadata +} + +func (request ListCertificateBundleVersionsRequest) String() string { + return common.PointerString(request) +} + +// HTTPRequest implements the OCIRequest interface +func (request ListCertificateBundleVersionsRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + _, err := request.ValidateEnumValue() + if err != nil { + return http.Request{}, err + } + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request ListCertificateBundleVersionsRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + +} + +// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. +func (request ListCertificateBundleVersionsRequest) RetryPolicy() *common.RetryPolicy { + return request.RequestMetadata.RetryPolicy +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (request ListCertificateBundleVersionsRequest) ValidateEnumValue() (bool, error) { + errMessage := []string{} + if _, ok := GetMappingListCertificateBundleVersionsSortByEnum(string(request.SortBy)); !ok && request.SortBy != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for SortBy: %s. Supported values are: %s.", request.SortBy, strings.Join(GetListCertificateBundleVersionsSortByEnumStringValues(), ","))) + } + if _, ok := GetMappingListCertificateBundleVersionsSortOrderEnum(string(request.SortOrder)); !ok && request.SortOrder != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for SortOrder: %s. Supported values are: %s.", request.SortOrder, strings.Join(GetListCertificateBundleVersionsSortOrderEnumStringValues(), ","))) + } + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} + +// ListCertificateBundleVersionsResponse wrapper for the ListCertificateBundleVersions operation +type ListCertificateBundleVersionsResponse struct { + + // The underlying http response + RawResponse *http.Response + + // The CertificateBundleVersionCollection instance + CertificateBundleVersionCollection `presentIn:"body"` + + // Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID. + OpcRequestId *string `presentIn:"header" name:"opc-request-id"` +} + +func (response ListCertificateBundleVersionsResponse) String() string { + return common.PointerString(response) +} + +// HTTPResponse implements the OCIResponse interface +func (response ListCertificateBundleVersionsResponse) HTTPResponse() *http.Response { + return response.RawResponse +} + +// ListCertificateBundleVersionsSortByEnum Enum with underlying type: string +type ListCertificateBundleVersionsSortByEnum string + +// Set of constants representing the allowable values for ListCertificateBundleVersionsSortByEnum +const ( + ListCertificateBundleVersionsSortByVersionNumber ListCertificateBundleVersionsSortByEnum = "VERSION_NUMBER" +) + +var mappingListCertificateBundleVersionsSortByEnum = map[string]ListCertificateBundleVersionsSortByEnum{ + "VERSION_NUMBER": ListCertificateBundleVersionsSortByVersionNumber, +} + +var mappingListCertificateBundleVersionsSortByEnumLowerCase = map[string]ListCertificateBundleVersionsSortByEnum{ + "version_number": ListCertificateBundleVersionsSortByVersionNumber, +} + +// GetListCertificateBundleVersionsSortByEnumValues Enumerates the set of values for ListCertificateBundleVersionsSortByEnum +func GetListCertificateBundleVersionsSortByEnumValues() []ListCertificateBundleVersionsSortByEnum { + values := make([]ListCertificateBundleVersionsSortByEnum, 0) + for _, v := range mappingListCertificateBundleVersionsSortByEnum { + values = append(values, v) + } + return values +} + +// GetListCertificateBundleVersionsSortByEnumStringValues Enumerates the set of values in String for ListCertificateBundleVersionsSortByEnum +func GetListCertificateBundleVersionsSortByEnumStringValues() []string { + return []string{ + "VERSION_NUMBER", + } +} + +// GetMappingListCertificateBundleVersionsSortByEnum performs case Insensitive comparison on enum value and return the desired enum +func GetMappingListCertificateBundleVersionsSortByEnum(val string) (ListCertificateBundleVersionsSortByEnum, bool) { + enum, ok := mappingListCertificateBundleVersionsSortByEnumLowerCase[strings.ToLower(val)] + return enum, ok +} + +// ListCertificateBundleVersionsSortOrderEnum Enum with underlying type: string +type ListCertificateBundleVersionsSortOrderEnum string + +// Set of constants representing the allowable values for ListCertificateBundleVersionsSortOrderEnum +const ( + ListCertificateBundleVersionsSortOrderAsc ListCertificateBundleVersionsSortOrderEnum = "ASC" + ListCertificateBundleVersionsSortOrderDesc ListCertificateBundleVersionsSortOrderEnum = "DESC" +) + +var mappingListCertificateBundleVersionsSortOrderEnum = map[string]ListCertificateBundleVersionsSortOrderEnum{ + "ASC": ListCertificateBundleVersionsSortOrderAsc, + "DESC": ListCertificateBundleVersionsSortOrderDesc, +} + +var mappingListCertificateBundleVersionsSortOrderEnumLowerCase = map[string]ListCertificateBundleVersionsSortOrderEnum{ + "asc": ListCertificateBundleVersionsSortOrderAsc, + "desc": ListCertificateBundleVersionsSortOrderDesc, +} + +// GetListCertificateBundleVersionsSortOrderEnumValues Enumerates the set of values for ListCertificateBundleVersionsSortOrderEnum +func GetListCertificateBundleVersionsSortOrderEnumValues() []ListCertificateBundleVersionsSortOrderEnum { + values := make([]ListCertificateBundleVersionsSortOrderEnum, 0) + for _, v := range mappingListCertificateBundleVersionsSortOrderEnum { + values = append(values, v) + } + return values +} + +// GetListCertificateBundleVersionsSortOrderEnumStringValues Enumerates the set of values in String for ListCertificateBundleVersionsSortOrderEnum +func GetListCertificateBundleVersionsSortOrderEnumStringValues() []string { + return []string{ + "ASC", + "DESC", + } +} + +// GetMappingListCertificateBundleVersionsSortOrderEnum performs case Insensitive comparison on enum value and return the desired enum +func GetMappingListCertificateBundleVersionsSortOrderEnum(val string) (ListCertificateBundleVersionsSortOrderEnum, bool) { + enum, ok := mappingListCertificateBundleVersionsSortOrderEnumLowerCase[strings.ToLower(val)] + return enum, ok +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/revocation_reason.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/revocation_reason.go new file mode 100644 index 00000000000..d423fc36453 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/revocation_reason.go @@ -0,0 +1,80 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "strings" +) + +// RevocationReasonEnum Enum with underlying type: string +type RevocationReasonEnum string + +// Set of constants representing the allowable values for RevocationReasonEnum +const ( + RevocationReasonUnspecified RevocationReasonEnum = "UNSPECIFIED" + RevocationReasonKeyCompromise RevocationReasonEnum = "KEY_COMPROMISE" + RevocationReasonCaCompromise RevocationReasonEnum = "CA_COMPROMISE" + RevocationReasonAffiliationChanged RevocationReasonEnum = "AFFILIATION_CHANGED" + RevocationReasonSuperseded RevocationReasonEnum = "SUPERSEDED" + RevocationReasonCessationOfOperation RevocationReasonEnum = "CESSATION_OF_OPERATION" + RevocationReasonPrivilegeWithdrawn RevocationReasonEnum = "PRIVILEGE_WITHDRAWN" + RevocationReasonAaCompromise RevocationReasonEnum = "AA_COMPROMISE" +) + +var mappingRevocationReasonEnum = map[string]RevocationReasonEnum{ + "UNSPECIFIED": RevocationReasonUnspecified, + "KEY_COMPROMISE": RevocationReasonKeyCompromise, + "CA_COMPROMISE": RevocationReasonCaCompromise, + "AFFILIATION_CHANGED": RevocationReasonAffiliationChanged, + "SUPERSEDED": RevocationReasonSuperseded, + "CESSATION_OF_OPERATION": RevocationReasonCessationOfOperation, + "PRIVILEGE_WITHDRAWN": RevocationReasonPrivilegeWithdrawn, + "AA_COMPROMISE": RevocationReasonAaCompromise, +} + +var mappingRevocationReasonEnumLowerCase = map[string]RevocationReasonEnum{ + "unspecified": RevocationReasonUnspecified, + "key_compromise": RevocationReasonKeyCompromise, + "ca_compromise": RevocationReasonCaCompromise, + "affiliation_changed": RevocationReasonAffiliationChanged, + "superseded": RevocationReasonSuperseded, + "cessation_of_operation": RevocationReasonCessationOfOperation, + "privilege_withdrawn": RevocationReasonPrivilegeWithdrawn, + "aa_compromise": RevocationReasonAaCompromise, +} + +// GetRevocationReasonEnumValues Enumerates the set of values for RevocationReasonEnum +func GetRevocationReasonEnumValues() []RevocationReasonEnum { + values := make([]RevocationReasonEnum, 0) + for _, v := range mappingRevocationReasonEnum { + values = append(values, v) + } + return values +} + +// GetRevocationReasonEnumStringValues Enumerates the set of values in String for RevocationReasonEnum +func GetRevocationReasonEnumStringValues() []string { + return []string{ + "UNSPECIFIED", + "KEY_COMPROMISE", + "CA_COMPROMISE", + "AFFILIATION_CHANGED", + "SUPERSEDED", + "CESSATION_OF_OPERATION", + "PRIVILEGE_WITHDRAWN", + "AA_COMPROMISE", + } +} + +// GetMappingRevocationReasonEnum performs case Insensitive comparison on enum value and return the desired enum +func GetMappingRevocationReasonEnum(val string) (RevocationReasonEnum, bool) { + enum, ok := mappingRevocationReasonEnumLowerCase[strings.ToLower(val)] + return enum, ok +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/revocation_status.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/revocation_status.go new file mode 100644 index 00000000000..6a82a679f26 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/revocation_status.go @@ -0,0 +1,45 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "strings" +) + +// RevocationStatus The current revocation status of the certificate or certificate authority (CA). +type RevocationStatus struct { + + // The time when the certificate or CA was revoked. + TimeRevoked *common.SDKTime `mandatory:"true" json:"timeRevoked"` + + // The reason that the certificate or CA was revoked. + RevocationReason RevocationReasonEnum `mandatory:"true" json:"revocationReason"` +} + +func (m RevocationStatus) String() string { + return common.PointerString(m) +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (m RevocationStatus) ValidateEnumValue() (bool, error) { + errMessage := []string{} + if _, ok := GetMappingRevocationReasonEnum(string(m.RevocationReason)); !ok && m.RevocationReason != "" { + errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for RevocationReason: %s. Supported values are: %s.", m.RevocationReason, strings.Join(GetRevocationReasonEnumStringValues(), ","))) + } + + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/validity.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/validity.go new file mode 100644 index 00000000000..a1d43dca42a --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/validity.go @@ -0,0 +1,44 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "fmt" + "github.com/oracle/oci-go-sdk/v65/common" + "strings" +) + +// Validity An object that describes a period of time during which an entity is valid. +type Validity struct { + + // The date on which the certificate validity period begins, expressed in RFC 3339 (https://tools.ietf.org/html/rfc3339) timestamp format. + // Example: `2019-04-03T21:10:29.600Z` + TimeOfValidityNotBefore *common.SDKTime `mandatory:"true" json:"timeOfValidityNotBefore"` + + // The date on which the certificate validity period ends, expressed in RFC 3339 (https://tools.ietf.org/html/rfc3339) timestamp format. + // Example: `2019-04-03T21:10:29.600Z` + TimeOfValidityNotAfter *common.SDKTime `mandatory:"true" json:"timeOfValidityNotAfter"` +} + +func (m Validity) String() string { + return common.PointerString(m) +} + +// ValidateEnumValue returns an error when providing an unsupported enum value +// This function is being called during constructing API request process +// Not recommended for calling this function directly +func (m Validity) ValidateEnumValue() (bool, error) { + errMessage := []string{} + + if len(errMessage) > 0 { + return true, fmt.Errorf(strings.Join(errMessage, "\n")) + } + return false, nil +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v65/certificates/version_stage.go b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/version_stage.go new file mode 100644 index 00000000000..e9287a90be1 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v65/certificates/version_stage.go @@ -0,0 +1,72 @@ +// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Certificates Service Retrieval API +// +// API for retrieving certificates. +// + +package certificates + +import ( + "strings" +) + +// VersionStageEnum Enum with underlying type: string +type VersionStageEnum string + +// Set of constants representing the allowable values for VersionStageEnum +const ( + VersionStageCurrent VersionStageEnum = "CURRENT" + VersionStagePending VersionStageEnum = "PENDING" + VersionStageLatest VersionStageEnum = "LATEST" + VersionStagePrevious VersionStageEnum = "PREVIOUS" + VersionStageDeprecated VersionStageEnum = "DEPRECATED" + VersionStageFailed VersionStageEnum = "FAILED" +) + +var mappingVersionStageEnum = map[string]VersionStageEnum{ + "CURRENT": VersionStageCurrent, + "PENDING": VersionStagePending, + "LATEST": VersionStageLatest, + "PREVIOUS": VersionStagePrevious, + "DEPRECATED": VersionStageDeprecated, + "FAILED": VersionStageFailed, +} + +var mappingVersionStageEnumLowerCase = map[string]VersionStageEnum{ + "current": VersionStageCurrent, + "pending": VersionStagePending, + "latest": VersionStageLatest, + "previous": VersionStagePrevious, + "deprecated": VersionStageDeprecated, + "failed": VersionStageFailed, +} + +// GetVersionStageEnumValues Enumerates the set of values for VersionStageEnum +func GetVersionStageEnumValues() []VersionStageEnum { + values := make([]VersionStageEnum, 0) + for _, v := range mappingVersionStageEnum { + values = append(values, v) + } + return values +} + +// GetVersionStageEnumStringValues Enumerates the set of values in String for VersionStageEnum +func GetVersionStageEnumStringValues() []string { + return []string{ + "CURRENT", + "PENDING", + "LATEST", + "PREVIOUS", + "DEPRECATED", + "FAILED", + } +} + +// GetMappingVersionStageEnum performs case Insensitive comparison on enum value and return the desired enum +func GetMappingVersionStageEnum(val string) (VersionStageEnum, bool) { + enum, ok := mappingVersionStageEnumLowerCase[strings.ToLower(val)] + return enum, ok +} diff --git a/website/docs/d/certificates_certificate_authority_bundle.html.markdown b/website/docs/d/certificates_certificate_authority_bundle.html.markdown new file mode 100644 index 00000000000..01b5d2a81a4 --- /dev/null +++ b/website/docs/d/certificates_certificate_authority_bundle.html.markdown @@ -0,0 +1,71 @@ +--- +subcategory: "Certificates" +layout: "oci" +page_title: "Oracle Cloud Infrastructure: oci_certificates_certificate_authority_bundle" +sidebar_current: "docs-oci-datasource-certificates-certificate_authority_bundle" +description: |- +Provides details about a certificate authority bundle in Oracle Cloud Infrastructure Certificates Retrieval service +--- + +# Data Source: oci_certificates_certificate_bundle +This data source provides details about a specific certificate authority bundle in Oracle Cloud Infrastructure Certificates Retrieval service. + +Gets details about the specified certificate authority bundle. + +## Example Usage + +```hcl +data "oci_certificates_certificate_authority_bundle" "test_certificate_authority_bundle" { + #Required + certificate_authority_id = oci_certificates_management_certificate_authority.test_certificate_authority.id + + #Optional + certificate_version_name = oci_certificates_management_certificate_authority.test_certificate_authority.current_version.version_name + stage = "CURRENT" + version_number = oci_certificates_management_certificate_authority.test_certificate_authority.current_version.version_number +} +``` + +## Argument Reference + +The following arguments are supported: + +* `certificate_authority_id` - (Required) The OCID of the certificate authority (CA). +* `certificate_version_name` - (Optional) The name of the certificate authority (CA). (This might be referred to as the +name of the CA version, as every CA consists of at least one version.) Names are unique across versions of a given CA. +* `stage` - (Optional) The rotation state of the certificate authority version. Valid values are: `CURRENT`, `PENDING`, +`LATEST`, `PREVIOUS` or `DEPRECATED`. +* `version_number` - (Optional) The version number of the certificate authority (CA). + +## Attributes Reference + +The following attributes are exported: + +* `cert_chain_pem` - The certificate chain (in PEM format) for this CA version. +* `certificate_authority_id` - The OCID of the certificate authority (CA). +* `certificate_authority_name` - The name of the CA. +* `certificate_pem` - The certificate (in PEM format) for this CA version. +* `revocation_status` - The revocation status of the certificate. +* `serial_number` - A unique certificate identifier used in certificate revocation tracking, formatted as octets. +* `stages` - A list of rotation states for this CA. +* `time_created` - An optional property indicating when the certificate version was created, expressed in RFC 3339 +timestamp format. +* `validity` - The validity of the certificate. +* `version_name` - The name of the CA version. +* `version_number` - The version number of the CA. + +### Revocation Status Reference + +The following attributes are exported: + +* `revocation_reason` - The reason that the CA was revoked. +* `time_revoked` - The time when the CA was revoked. + +### Validity Reference + +The following attributes are exported: + +* `time_of_validity_not_after` - The date on which the CA validity period ends, expressed in RFC 3339 timestamp +format. +* `time_of_validity_not_before` - The date on which the CA validity period begins, expressed in RFC 3339 +timestamp format. diff --git a/website/docs/d/certificates_certificate_bundle.html.markdown b/website/docs/d/certificates_certificate_bundle.html.markdown new file mode 100644 index 00000000000..b0d0a5e1805 --- /dev/null +++ b/website/docs/d/certificates_certificate_bundle.html.markdown @@ -0,0 +1,82 @@ +--- +subcategory: "Certificates" +layout: "oci" +page_title: "Oracle Cloud Infrastructure: oci_certificates_certificate_bundle" +sidebar_current: "docs-oci-datasource-certificates-certificate_bundle" +description: |- +Provides details about a certificate bundle in Oracle Cloud Infrastructure Certificates Retrieval service +--- + +# Data Source: oci_certificates_certificate_bundle +This data source provides details about a specific certificate bundle in Oracle Cloud Infrastructure Certificates Retrieval service. + +Gets details about the specified certificate bundle. + +## Example Usage + +```hcl +data "oci_certificates_certificate_bundle" "test_certificate_bundle" { + #Required + certificate_id = oci_certificates_management_certificate.test_certificate.id + + #Optional + certificate_bundle_type = "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY" + certificate_version_name = oci_certificates_management_certificate.test_certificate.current_version.version_name + stage = "CURRENT" + version_number = oci_certificates_management_certificate.test_certificate.current_version.version_number +} +``` + +## Argument Reference + +The following arguments are supported: + +* `certificate_id` - (Required) The OCID of the certificate. +* `certificate_bundle_type` - (Optional) The type of certificate bundle. By default, the private key fields are not +returned. When querying for certificate bundles, to return results with certificate contents, the private key in PEM +format, and the private key passphrase, specify the value of this parameter as CERTIFICATE_CONTENT_WITH_PRIVATE_KEY. +Valid values are: `CERTIFICATE_CONTENT_PUBLIC_ONLY` or `CERTIFICATE_CONTENT_WITH_PRIVATE_KEY`. +* `certificate_version_name` - (Optional) The name of the certificate. (This might be referred to as the name of the +certificate version, as every certificate consists of at least one version.) Names are unique across versions of a +given certificate. +* `stage` - (Optional) The rotation state of the certificate version. Valid values are: `CURRENT`, `PENDING`, `LATEST`, +`PREVIOUS` or `DEPRECATED`. +* `version_number` - (Optional) The version number of the certificate. + +## Attributes Reference + +The following attributes are exported: + +* `cert_chain_pem` - The certificate chain (in PEM format) for the certificate bundle. +* `certificate_bundle_type` - The type of certificate bundle, which indicates whether the private key fields are included. +* `certificate_id` - The OCID of the certificate. +* `certificate_name` - The name of the certificate. +* `certificate_pem` - The certificate (in PEM format) for the certificate bundle. +* `private_key_pem` - The private key (in PEM format) for the certificate. This is only set if `certificate_bundle_type` +is set to `CERTIFICATE_CONTENT_WITH_PRIVATE_KEY`. +* `private_key_pem_passphrase` - The passphrase for the private key. This is only set if `certificate_bundle_type` +is set to `CERTIFICATE_CONTENT_WITH_PRIVATE_KEY`. +* `revocation_status` - The revocation status of the certificate. +* `serial_number` - A unique certificate identifier used in certificate revocation tracking, formatted as octets. +* `stages` - A list of rotation states for the certificate bundle. +* `time_created` - An optional property indicating when the certificate version was created, expressed in RFC 3339 +timestamp format. +* `validity` - The validity of the certificate. +* `version_name` - The name of the certificate version. +* `version_number` - The version number of the certificate. + +### Revocation Status Reference + +The following attributes are exported: + +* `revocation_reason` - The reason that the certificate was revoked. +* `time_revoked` - The time when the certificate was revoked. + +### Validity Reference + +The following attributes are exported: + +* `time_of_validity_not_after` - The date on which the certificate validity period ends, expressed in RFC 3339 timestamp +format. +* `time_of_validity_not_before` - The date on which the certificate validity period begins, expressed in RFC 3339 +timestamp format.