Skip to content

Commit 4440c31

Browse files
ccushingrcohenma
authored andcommitted
Support Streaming service
1 parent 91c70b3 commit 4440c31

13 files changed

+1191
-16
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
## 3.15.1 (Unreleased)
2-
Enable regional Subnets by making Availability Domain optional when creating a Subnet
1+
## 3.16.0 (Unreleased)
32

43
### Added
54
- Adding description property to rules in Steering Policies in DNS
5+
- Enable regional Subnets by making Availability Domain optional when creating a Subnet
6+
- Support for Streaming service
67

78
### Fixed
89
- DNS Record now requires domain and rtype as mandatory arguments. Managing DNS record resources now requires DNS_RECORD* level policy entitlements instead of DNS_ZONE*. [Permissions List](https://docs.cloud.oracle.com/iaas/Content/Identity/Reference/dnspolicyreference.htm)

docs/examples/streaming/main.tf

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
variable "tenancy_ocid" {}
2+
variable "user_ocid" {}
3+
variable "fingerprint" {}
4+
variable "private_key_path" {}
5+
variable "region" {}
6+
7+
provider "oci" {
8+
tenancy_ocid = "${var.tenancy_ocid}"
9+
user_ocid = "${var.user_ocid}"
10+
fingerprint = "${var.fingerprint}"
11+
private_key_path = "${var.private_key_path}"
12+
region = "${var.region}"
13+
}
14+
15+
resource "oci_streaming_stream" "stream" {
16+
compartment_id = "${var.tenancy_ocid}"
17+
name = "stream1"
18+
partitions = "1"
19+
retention_in_hours = "24"
20+
}
21+
22+
data "oci_streaming_stream" "stream1" {
23+
stream_id = "${oci_streaming_stream.stream.id}"
24+
}
25+
26+
# Output the result
27+
output "stream" {
28+
value = <<EOF
29+
30+
id = "${data.oci_streaming_stream.stream1.id}"
31+
compartment_id = "${data.oci_streaming_stream.stream1.compartment_id}"
32+
messages_endpoint = "${data.oci_streaming_stream.stream1.messages_endpoint}"
33+
name = "${data.oci_streaming_stream.stream1.name}"
34+
partitions = "${data.oci_streaming_stream.stream1.partitions}"
35+
retention_in_hours = "${data.oci_streaming_stream.stream1.retention_in_hours}"
36+
state = "${data.oci_streaming_stream.stream1.state}"
37+
time_created = "${data.oci_streaming_stream.stream1.time_created}"
38+
EOF
39+
40+
# This value is not always present--when state is FAILED it may contain an explanation.
41+
#lifecycle_state_details = "${data.oci_streaming_stream.stream1.lifecycle_state_details}"
42+
}
43+
44+
data "oci_streaming_streams" "streams" {
45+
compartment_id = "${oci_streaming_stream.stream.compartment_id}"
46+
47+
# optional
48+
state = "ACTIVE"
49+
50+
// id = "${oci_streaming_stream.stream.id}"
51+
// name = "${oci_streaming_stream.stream.name}"
52+
}
53+
54+
output "streams" {
55+
value = "${data.oci_streaming_streams.streams.streams}"
56+
}

oci/provider.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,13 @@ func dataSourcesMap() map[string]*schema.Resource {
316316
"oci_file_storage_file_systems": FileStorageFileSystemsDataSource(),
317317
"oci_file_storage_mount_targets": FileStorageMountTargetsDataSource(),
318318
"oci_file_storage_snapshots": FileStorageSnapshotsDataSource(),
319+
"oci_health_checks_http_monitor": HealthChecksHttpMonitorDataSource(),
320+
"oci_health_checks_http_monitors": HealthChecksHttpMonitorsDataSource(),
321+
"oci_health_checks_ping_monitor": HealthChecksPingMonitorDataSource(),
322+
"oci_health_checks_ping_monitors": HealthChecksPingMonitorsDataSource(),
323+
"oci_health_checks_http_probe_results": HealthChecksHttpProbeResultsDataSource(),
324+
"oci_health_checks_ping_probe_results": HealthChecksPingProbeResultsDataSource(),
325+
"oci_health_checks_vantage_points": HealthChecksVantagePointsDataSource(),
319326
"oci_identity_api_keys": IdentityApiKeysDataSource(),
320327
"oci_identity_auth_tokens": IdentityAuthTokensDataSource(),
321328
"oci_identity_availability_domains": IdentityAvailabilityDomainsDataSource(),
@@ -372,13 +379,8 @@ func dataSourcesMap() map[string]*schema.Resource {
372379
"oci_objectstorage_objects": ObjectStorageObjectsDataSource(),
373380
"oci_objectstorage_preauthrequest": ObjectStoragePreauthenticatedRequestDataSource(),
374381
"oci_objectstorage_preauthrequests": ObjectStoragePreauthenticatedRequestsDataSource(),
375-
"oci_health_checks_http_monitor": HealthChecksHttpMonitorDataSource(),
376-
"oci_health_checks_http_monitors": HealthChecksHttpMonitorsDataSource(),
377-
"oci_health_checks_ping_monitor": HealthChecksPingMonitorDataSource(),
378-
"oci_health_checks_ping_monitors": HealthChecksPingMonitorsDataSource(),
379-
"oci_health_checks_http_probe_results": HealthChecksHttpProbeResultsDataSource(),
380-
"oci_health_checks_ping_probe_results": HealthChecksPingProbeResultsDataSource(),
381-
"oci_health_checks_vantage_points": HealthChecksVantagePointsDataSource(),
382+
"oci_streaming_stream": StreamingStreamDataSource(),
383+
"oci_streaming_streams": StreamingStreamsDataSource(),
382384
}
383385
}
384386

@@ -448,6 +450,10 @@ func resourcesMap() map[string]*schema.Resource {
448450
"oci_file_storage_file_system": FileStorageFileSystemResource(),
449451
"oci_file_storage_mount_target": FileStorageMountTargetResource(),
450452
"oci_file_storage_snapshot": FileStorageSnapshotResource(),
453+
"oci_health_checks_http_monitor": HealthChecksHttpMonitorResource(),
454+
"oci_health_checks_ping_monitor": HealthChecksPingMonitorResource(),
455+
"oci_health_checks_http_probe": HealthChecksHttpProbeResource(),
456+
"oci_health_checks_ping_probe": HealthChecksPingProbeResource(),
451457
"oci_identity_api_key": IdentityApiKeyResource(),
452458
"oci_identity_auth_token": IdentityAuthTokenResource(),
453459
"oci_identity_compartment": IdentityCompartmentResource(),
@@ -485,10 +491,7 @@ func resourcesMap() map[string]*schema.Resource {
485491
"oci_objectstorage_object": ObjectStorageObjectResource(),
486492
"oci_objectstorage_namespace_metadata": ObjectStorageNamespaceMetadataResource(),
487493
"oci_objectstorage_preauthrequest": ObjectStoragePreauthenticatedRequestResource(),
488-
"oci_health_checks_http_monitor": HealthChecksHttpMonitorResource(),
489-
"oci_health_checks_ping_monitor": HealthChecksPingMonitorResource(),
490-
"oci_health_checks_http_probe": HealthChecksHttpProbeResource(),
491-
"oci_health_checks_ping_probe": HealthChecksPingProbeResource(),
494+
"oci_streaming_stream": StreamingStreamResource(),
492495
}
493496
}
494497

oci/provider_clients.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
oci_kms "github.com/oracle/oci-go-sdk/keymanagement"
2424
oci_load_balancer "github.com/oracle/oci-go-sdk/loadbalancer"
2525
oci_object_storage "github.com/oracle/oci-go-sdk/objectstorage"
26+
oci_streaming "github.com/oracle/oci-go-sdk/streaming"
2627

2728
oci_common "github.com/oracle/oci-go-sdk/common"
2829
)
@@ -98,6 +99,10 @@ func setGoSDKClients(clients *OracleClients, officialSdkConfigProvider oci_commo
9899
if err != nil {
99100
return
100101
}
102+
streamAdminClient, err := oci_streaming.NewStreamAdminClientWithConfigurationProvider(officialSdkConfigProvider)
103+
if err != nil {
104+
return
105+
}
101106
virtualNetworkClient, err := oci_core.NewVirtualNetworkClientWithConfigurationProvider(officialSdkConfigProvider)
102107
if err != nil {
103108
return
@@ -246,6 +251,10 @@ func setGoSDKClients(clients *OracleClients, officialSdkConfigProvider oci_commo
246251
if err != nil {
247252
return
248253
}
254+
err = configureClient(&streamAdminClient.BaseClient)
255+
if err != nil {
256+
return
257+
}
249258
err = configureClient(&virtualNetworkClient.BaseClient)
250259
if err != nil {
251260
return
@@ -267,6 +276,7 @@ func setGoSDKClients(clients *OracleClients, officialSdkConfigProvider oci_commo
267276
clients.kmsVaultClient = &kmsVaultClient
268277
clients.loadBalancerClient = &loadBalancerClient
269278
clients.objectStorageClient = &objectStorageClient
279+
clients.streamAdminClient = &streamAdminClient
270280
clients.virtualNetworkClient = &virtualNetworkClient
271281

272282
return
@@ -289,6 +299,7 @@ type OracleClients struct {
289299
kmsVaultClient *oci_kms.KmsVaultClient
290300
loadBalancerClient *oci_load_balancer.LoadBalancerClient
291301
objectStorageClient *oci_object_storage.ObjectStorageClient
302+
streamAdminClient *oci_streaming.StreamAdminClient
292303
virtualNetworkClient *oci_core.VirtualNetworkClient
293304
configuration map[string]string
294305
}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
// Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
3+
package provider
4+
5+
import (
6+
"context"
7+
8+
"github.com/hashicorp/terraform/helper/schema"
9+
oci_streaming "github.com/oracle/oci-go-sdk/streaming"
10+
)
11+
12+
func StreamingStreamDataSource() *schema.Resource {
13+
return &schema.Resource{
14+
Read: readSingularStreamingStream,
15+
Schema: map[string]*schema.Schema{
16+
"stream_id": {
17+
Type: schema.TypeString,
18+
Required: true,
19+
},
20+
// Computed
21+
"compartment_id": {
22+
Type: schema.TypeString,
23+
Computed: true,
24+
},
25+
"defined_tags": {
26+
Type: schema.TypeMap,
27+
Computed: true,
28+
Elem: schema.TypeString,
29+
},
30+
"freeform_tags": {
31+
Type: schema.TypeMap,
32+
Computed: true,
33+
Elem: schema.TypeString,
34+
},
35+
"lifecycle_state_details": {
36+
Type: schema.TypeString,
37+
Computed: true,
38+
},
39+
"messages_endpoint": {
40+
Type: schema.TypeString,
41+
Computed: true,
42+
},
43+
"name": {
44+
Type: schema.TypeString,
45+
Computed: true,
46+
},
47+
"partitions": {
48+
Type: schema.TypeInt,
49+
Computed: true,
50+
},
51+
"retention_in_hours": {
52+
Type: schema.TypeInt,
53+
Computed: true,
54+
},
55+
"state": {
56+
Type: schema.TypeString,
57+
Computed: true,
58+
},
59+
"time_created": {
60+
Type: schema.TypeString,
61+
Computed: true,
62+
},
63+
},
64+
}
65+
}
66+
67+
func readSingularStreamingStream(d *schema.ResourceData, m interface{}) error {
68+
sync := &StreamingStreamDataSourceCrud{}
69+
sync.D = d
70+
sync.Client = m.(*OracleClients).streamAdminClient
71+
72+
return ReadResource(sync)
73+
}
74+
75+
type StreamingStreamDataSourceCrud struct {
76+
D *schema.ResourceData
77+
Client *oci_streaming.StreamAdminClient
78+
Res *oci_streaming.GetStreamResponse
79+
}
80+
81+
func (s *StreamingStreamDataSourceCrud) VoidState() {
82+
s.D.SetId("")
83+
}
84+
85+
func (s *StreamingStreamDataSourceCrud) Get() error {
86+
request := oci_streaming.GetStreamRequest{}
87+
88+
if streamId, ok := s.D.GetOkExists("stream_id"); ok {
89+
tmp := streamId.(string)
90+
request.StreamId = &tmp
91+
}
92+
93+
request.RequestMetadata.RetryPolicy = getRetryPolicy(false, "streaming")
94+
95+
response, err := s.Client.GetStream(context.Background(), request)
96+
if err != nil {
97+
return err
98+
}
99+
100+
s.Res = &response
101+
return nil
102+
}
103+
104+
func (s *StreamingStreamDataSourceCrud) SetData() error {
105+
if s.Res == nil {
106+
return nil
107+
}
108+
109+
s.D.SetId(*s.Res.Id)
110+
111+
if s.Res.CompartmentId != nil {
112+
s.D.Set("compartment_id", *s.Res.CompartmentId)
113+
}
114+
115+
if s.Res.DefinedTags != nil {
116+
s.D.Set("defined_tags", definedTagsToMap(s.Res.DefinedTags))
117+
}
118+
119+
s.D.Set("freeform_tags", s.Res.FreeformTags)
120+
121+
if s.Res.LifecycleStateDetails != nil {
122+
s.D.Set("lifecycle_state_details", *s.Res.LifecycleStateDetails)
123+
}
124+
125+
if s.Res.MessagesEndpoint != nil {
126+
s.D.Set("messages_endpoint", *s.Res.MessagesEndpoint)
127+
}
128+
129+
if s.Res.Name != nil {
130+
s.D.Set("name", *s.Res.Name)
131+
}
132+
133+
if s.Res.Partitions != nil {
134+
s.D.Set("partitions", *s.Res.Partitions)
135+
}
136+
137+
if s.Res.RetentionInHours != nil {
138+
s.D.Set("retention_in_hours", *s.Res.RetentionInHours)
139+
}
140+
141+
s.D.Set("state", s.Res.LifecycleState)
142+
143+
if s.Res.TimeCreated != nil {
144+
s.D.Set("time_created", s.Res.TimeCreated.String())
145+
}
146+
147+
return nil
148+
}

0 commit comments

Comments
 (0)