Skip to content

Commit 8f9d7f2

Browse files
Monica Jimenezvarmax2511
authored andcommitted
Added support for BDS - Object Store Integration
1 parent e866934 commit 8f9d7f2

13 files changed

+1289
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "tenancy_ocid" {}
5+
variable "user_ocid" {}
6+
variable "fingerprint" {}
7+
variable "private_key_path" {}
8+
variable "region" {}
9+
variable "bds_instance_id" {}
10+
11+
variable "bds_instance_api_key_default_region" {
12+
default = "us-ashburn-1"
13+
}
14+
15+
variable "bds_instance_api_key_display_name" {
16+
default = "keyAlias"
17+
}
18+
19+
variable "bds_instance_api_key_key_alias" {
20+
default = "keyAlias"
21+
}
22+
23+
variable "bds_instance_api_key_passphrase" {
24+
default = "V2VsY29tZTE="
25+
}
26+
27+
variable "bds_instance_api_key_state" {
28+
default = "ACTIVE"
29+
}
30+
31+
32+
33+
provider "oci" {
34+
tenancy_ocid = var.tenancy_ocid
35+
user_ocid = var.user_ocid
36+
fingerprint = var.fingerprint
37+
private_key_path = var.private_key_path
38+
region = var.region
39+
}
40+
41+
resource "oci_bds_bds_instance_api_key" "test_bds_instance_api_key" {
42+
#Required
43+
bds_instance_id = var.bds_instance_id
44+
key_alias = var.bds_instance_api_key_key_alias
45+
passphrase = var.bds_instance_api_key_passphrase
46+
user_id = var.user_ocid
47+
48+
#Optional
49+
default_region = var.bds_instance_api_key_default_region
50+
}
51+
52+
data "oci_bds_bds_instance_api_keys" "test_bds_instance_api_keys" {
53+
#Required
54+
bds_instance_id = var.bds_instance_id
55+
56+
#Optional
57+
state = var.bds_instance_api_key_state
58+
}
59+
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package oci
5+
6+
import (
7+
"context"
8+
9+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
10+
oci_bds "github.com/oracle/oci-go-sdk/v54/bds"
11+
)
12+
13+
func init() {
14+
RegisterDatasource("oci_bds_bds_instance_api_key", BdsBdsInstanceApiKeyDataSource())
15+
}
16+
17+
func BdsBdsInstanceApiKeyDataSource() *schema.Resource {
18+
fieldMap := make(map[string]*schema.Schema)
19+
fieldMap["api_key_id"] = &schema.Schema{
20+
Type: schema.TypeString,
21+
Required: true,
22+
}
23+
fieldMap["bds_instance_id"] = &schema.Schema{
24+
Type: schema.TypeString,
25+
Required: true,
26+
}
27+
return GetSingularDataSourceItemSchema(BdsBdsInstanceApiKeyResource(), fieldMap, readSingularBdsBdsInstanceApiKey)
28+
}
29+
30+
func readSingularBdsBdsInstanceApiKey(d *schema.ResourceData, m interface{}) error {
31+
sync := &BdsBdsInstanceApiKeyDataSourceCrud{}
32+
sync.D = d
33+
sync.Client = m.(*OracleClients).bdsClient()
34+
35+
return ReadResource(sync)
36+
}
37+
38+
type BdsBdsInstanceApiKeyDataSourceCrud struct {
39+
D *schema.ResourceData
40+
Client *oci_bds.BdsClient
41+
Res *oci_bds.GetBdsApiKeyResponse
42+
}
43+
44+
func (s *BdsBdsInstanceApiKeyDataSourceCrud) VoidState() {
45+
s.D.SetId("")
46+
}
47+
48+
func (s *BdsBdsInstanceApiKeyDataSourceCrud) Get() error {
49+
request := oci_bds.GetBdsApiKeyRequest{}
50+
51+
if apiKeyId, ok := s.D.GetOkExists("api_key_id"); ok {
52+
tmp := apiKeyId.(string)
53+
request.ApiKeyId = &tmp
54+
}
55+
56+
if bdsInstanceId, ok := s.D.GetOkExists("bds_instance_id"); ok {
57+
tmp := bdsInstanceId.(string)
58+
request.BdsInstanceId = &tmp
59+
}
60+
61+
request.RequestMetadata.RetryPolicy = GetRetryPolicy(false, "bds")
62+
63+
response, err := s.Client.GetBdsApiKey(context.Background(), request)
64+
if err != nil {
65+
return err
66+
}
67+
68+
s.Res = &response
69+
return nil
70+
}
71+
72+
func (s *BdsBdsInstanceApiKeyDataSourceCrud) SetData() error {
73+
if s.Res == nil {
74+
return nil
75+
}
76+
77+
s.D.SetId(*s.Res.Id)
78+
79+
if s.Res.DefaultRegion != nil {
80+
s.D.Set("default_region", *s.Res.DefaultRegion)
81+
}
82+
83+
if s.Res.Fingerprint != nil {
84+
s.D.Set("fingerprint", *s.Res.Fingerprint)
85+
}
86+
87+
if s.Res.KeyAlias != nil {
88+
s.D.Set("key_alias", *s.Res.KeyAlias)
89+
}
90+
91+
if s.Res.Pemfilepath != nil {
92+
s.D.Set("pemfilepath", *s.Res.Pemfilepath)
93+
}
94+
95+
s.D.Set("state", s.Res.LifecycleState)
96+
97+
if s.Res.TenantId != nil {
98+
s.D.Set("tenant_id", *s.Res.TenantId)
99+
}
100+
101+
if s.Res.TimeCreated != nil {
102+
s.D.Set("time_created", s.Res.TimeCreated.String())
103+
}
104+
105+
if s.Res.UserId != nil {
106+
s.D.Set("user_id", *s.Res.UserId)
107+
}
108+
109+
return nil
110+
}

0 commit comments

Comments
 (0)