Skip to content

Commit 6357126

Browse files
Add GCS ingestion settings and platform log settings to google_pubsub_topic (#11823)
Co-authored-by: Cameron Thornton <[email protected]> [upstream:cce9010088bec8cc7bc2d62b99f6e90a6551db1b] Signed-off-by: Modular Magician <[email protected]>
1 parent ba76d78 commit 6357126

File tree

5 files changed

+565
-0
lines changed

5 files changed

+565
-0
lines changed

.changelog/11823.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
pubsub: added GCS ingestion settings and platform log settings to `google_pubsub_topic` resource
3+
```

google-beta/services/pubsub/resource_pubsub_topic.go

+342
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,103 @@ equals to this service account number.`,
106106
},
107107
},
108108
},
109+
ConflictsWith: []string{},
110+
},
111+
"cloud_storage": {
112+
Type: schema.TypeList,
113+
Optional: true,
114+
Description: `Settings for ingestion from Cloud Storage.`,
115+
MaxItems: 1,
116+
Elem: &schema.Resource{
117+
Schema: map[string]*schema.Schema{
118+
"bucket": {
119+
Type: schema.TypeString,
120+
Required: true,
121+
Description: `Cloud Storage bucket. The bucket name must be without any
122+
prefix like "gs://". See the bucket naming requirements:
123+
https://cloud.google.com/storage/docs/buckets#naming.`,
124+
},
125+
"avro_format": {
126+
Type: schema.TypeList,
127+
Optional: true,
128+
Description: `Configuration for reading Cloud Storage data in Avro binary format. The
129+
bytes of each object will be set to the 'data' field of a Pub/Sub message.`,
130+
MaxItems: 1,
131+
Elem: &schema.Resource{
132+
Schema: map[string]*schema.Schema{},
133+
},
134+
ExactlyOneOf: []string{},
135+
},
136+
"match_glob": {
137+
Type: schema.TypeString,
138+
Optional: true,
139+
Description: `Glob pattern used to match objects that will be ingested. If unset, all
140+
objects will be ingested. See the supported patterns:
141+
https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-objects-and-prefixes-using-glob`,
142+
},
143+
"minimum_object_create_time": {
144+
Type: schema.TypeString,
145+
Optional: true,
146+
Description: `The timestamp set in RFC3339 text format. If set, only objects with a
147+
larger or equal timestamp will be ingested. Unset by default, meaning
148+
all objects will be ingested.`,
149+
},
150+
"pubsub_avro_format": {
151+
Type: schema.TypeList,
152+
Optional: true,
153+
Description: `Configuration for reading Cloud Storage data written via Cloud Storage
154+
subscriptions(See https://cloud.google.com/pubsub/docs/cloudstorage). The
155+
data and attributes fields of the originally exported Pub/Sub message
156+
will be restored when publishing.`,
157+
MaxItems: 1,
158+
Elem: &schema.Resource{
159+
Schema: map[string]*schema.Schema{},
160+
},
161+
ExactlyOneOf: []string{},
162+
},
163+
"text_format": {
164+
Type: schema.TypeList,
165+
Optional: true,
166+
Description: `Configuration for reading Cloud Storage data in text format. Each line of
167+
text as specified by the delimiter will be set to the 'data' field of a
168+
Pub/Sub message.`,
169+
MaxItems: 1,
170+
Elem: &schema.Resource{
171+
Schema: map[string]*schema.Schema{
172+
"delimiter": {
173+
Type: schema.TypeString,
174+
Optional: true,
175+
Description: `The delimiter to use when using the 'text' format. Each line of text as
176+
specified by the delimiter will be set to the 'data' field of a Pub/Sub
177+
message. When unset, '\n' is used.`,
178+
Default: "\n",
179+
},
180+
},
181+
},
182+
ExactlyOneOf: []string{},
183+
},
184+
},
185+
},
186+
ConflictsWith: []string{},
187+
},
188+
"platform_logs_settings": {
189+
Type: schema.TypeList,
190+
Optional: true,
191+
Description: `Settings for Platform Logs regarding ingestion to Pub/Sub. If unset,
192+
no Platform Logs will be generated.'`,
193+
MaxItems: 1,
194+
Elem: &schema.Resource{
195+
Schema: map[string]*schema.Schema{
196+
"severity": {
197+
Type: schema.TypeString,
198+
Optional: true,
199+
ValidateFunc: verify.ValidateEnum([]string{"SEVERITY_UNSPECIFIED", "DISABLED", "DEBUG", "INFO", "WARNING", "ERROR", ""}),
200+
Description: `The minimum severity level of Platform Logs that will be written. If unspecified,
201+
no Platform Logs will be written. Default value: "SEVERITY_UNSPECIFIED" Possible values: ["SEVERITY_UNSPECIFIED", "DISABLED", "DEBUG", "INFO", "WARNING", "ERROR"]`,
202+
Default: "SEVERITY_UNSPECIFIED",
203+
},
204+
},
205+
},
109206
},
110207
},
111208
},
@@ -718,6 +815,10 @@ func flattenPubsubTopicIngestionDataSourceSettings(v interface{}, d *schema.Reso
718815
transformed := make(map[string]interface{})
719816
transformed["aws_kinesis"] =
720817
flattenPubsubTopicIngestionDataSourceSettingsAwsKinesis(original["awsKinesis"], d, config)
818+
transformed["cloud_storage"] =
819+
flattenPubsubTopicIngestionDataSourceSettingsCloudStorage(original["cloudStorage"], d, config)
820+
transformed["platform_logs_settings"] =
821+
flattenPubsubTopicIngestionDataSourceSettingsPlatformLogsSettings(original["platformLogsSettings"], d, config)
721822
return []interface{}{transformed}
722823
}
723824
func flattenPubsubTopicIngestionDataSourceSettingsAwsKinesis(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -755,6 +856,91 @@ func flattenPubsubTopicIngestionDataSourceSettingsAwsKinesisGcpServiceAccount(v
755856
return v
756857
}
757858

859+
func flattenPubsubTopicIngestionDataSourceSettingsCloudStorage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
860+
if v == nil {
861+
return nil
862+
}
863+
original := v.(map[string]interface{})
864+
if len(original) == 0 {
865+
return nil
866+
}
867+
transformed := make(map[string]interface{})
868+
transformed["bucket"] =
869+
flattenPubsubTopicIngestionDataSourceSettingsCloudStorageBucket(original["bucket"], d, config)
870+
transformed["text_format"] =
871+
flattenPubsubTopicIngestionDataSourceSettingsCloudStorageTextFormat(original["textFormat"], d, config)
872+
transformed["avro_format"] =
873+
flattenPubsubTopicIngestionDataSourceSettingsCloudStorageAvroFormat(original["avroFormat"], d, config)
874+
transformed["pubsub_avro_format"] =
875+
flattenPubsubTopicIngestionDataSourceSettingsCloudStoragePubsubAvroFormat(original["pubsubAvroFormat"], d, config)
876+
transformed["minimum_object_create_time"] =
877+
flattenPubsubTopicIngestionDataSourceSettingsCloudStorageMinimumObjectCreateTime(original["minimumObjectCreateTime"], d, config)
878+
transformed["match_glob"] =
879+
flattenPubsubTopicIngestionDataSourceSettingsCloudStorageMatchGlob(original["matchGlob"], d, config)
880+
return []interface{}{transformed}
881+
}
882+
func flattenPubsubTopicIngestionDataSourceSettingsCloudStorageBucket(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
883+
return v
884+
}
885+
886+
func flattenPubsubTopicIngestionDataSourceSettingsCloudStorageTextFormat(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
887+
if v == nil {
888+
return nil
889+
}
890+
original := v.(map[string]interface{})
891+
if len(original) == 0 {
892+
return nil
893+
}
894+
transformed := make(map[string]interface{})
895+
transformed["delimiter"] =
896+
flattenPubsubTopicIngestionDataSourceSettingsCloudStorageTextFormatDelimiter(original["delimiter"], d, config)
897+
return []interface{}{transformed}
898+
}
899+
func flattenPubsubTopicIngestionDataSourceSettingsCloudStorageTextFormatDelimiter(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
900+
return v
901+
}
902+
903+
func flattenPubsubTopicIngestionDataSourceSettingsCloudStorageAvroFormat(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
904+
if v == nil {
905+
return nil
906+
}
907+
transformed := make(map[string]interface{})
908+
return []interface{}{transformed}
909+
}
910+
911+
func flattenPubsubTopicIngestionDataSourceSettingsCloudStoragePubsubAvroFormat(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
912+
if v == nil {
913+
return nil
914+
}
915+
transformed := make(map[string]interface{})
916+
return []interface{}{transformed}
917+
}
918+
919+
func flattenPubsubTopicIngestionDataSourceSettingsCloudStorageMinimumObjectCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
920+
return v
921+
}
922+
923+
func flattenPubsubTopicIngestionDataSourceSettingsCloudStorageMatchGlob(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
924+
return v
925+
}
926+
927+
func flattenPubsubTopicIngestionDataSourceSettingsPlatformLogsSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
928+
if v == nil {
929+
return nil
930+
}
931+
original := v.(map[string]interface{})
932+
if len(original) == 0 {
933+
return nil
934+
}
935+
transformed := make(map[string]interface{})
936+
transformed["severity"] =
937+
flattenPubsubTopicIngestionDataSourceSettingsPlatformLogsSettingsSeverity(original["severity"], d, config)
938+
return []interface{}{transformed}
939+
}
940+
func flattenPubsubTopicIngestionDataSourceSettingsPlatformLogsSettingsSeverity(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
941+
return v
942+
}
943+
758944
func flattenPubsubTopicTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
759945
if v == nil {
760946
return v
@@ -859,6 +1045,20 @@ func expandPubsubTopicIngestionDataSourceSettings(v interface{}, d tpgresource.T
8591045
transformed["awsKinesis"] = transformedAwsKinesis
8601046
}
8611047

1048+
transformedCloudStorage, err := expandPubsubTopicIngestionDataSourceSettingsCloudStorage(original["cloud_storage"], d, config)
1049+
if err != nil {
1050+
return nil, err
1051+
} else if val := reflect.ValueOf(transformedCloudStorage); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1052+
transformed["cloudStorage"] = transformedCloudStorage
1053+
}
1054+
1055+
transformedPlatformLogsSettings, err := expandPubsubTopicIngestionDataSourceSettingsPlatformLogsSettings(original["platform_logs_settings"], d, config)
1056+
if err != nil {
1057+
return nil, err
1058+
} else if val := reflect.ValueOf(transformedPlatformLogsSettings); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1059+
transformed["platformLogsSettings"] = transformedPlatformLogsSettings
1060+
}
1061+
8621062
return transformed, nil
8631063
}
8641064

@@ -918,6 +1118,148 @@ func expandPubsubTopicIngestionDataSourceSettingsAwsKinesisGcpServiceAccount(v i
9181118
return v, nil
9191119
}
9201120

1121+
func expandPubsubTopicIngestionDataSourceSettingsCloudStorage(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1122+
l := v.([]interface{})
1123+
if len(l) == 0 || l[0] == nil {
1124+
return nil, nil
1125+
}
1126+
raw := l[0]
1127+
original := raw.(map[string]interface{})
1128+
transformed := make(map[string]interface{})
1129+
1130+
transformedBucket, err := expandPubsubTopicIngestionDataSourceSettingsCloudStorageBucket(original["bucket"], d, config)
1131+
if err != nil {
1132+
return nil, err
1133+
} else if val := reflect.ValueOf(transformedBucket); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1134+
transformed["bucket"] = transformedBucket
1135+
}
1136+
1137+
transformedTextFormat, err := expandPubsubTopicIngestionDataSourceSettingsCloudStorageTextFormat(original["text_format"], d, config)
1138+
if err != nil {
1139+
return nil, err
1140+
} else if val := reflect.ValueOf(transformedTextFormat); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1141+
transformed["textFormat"] = transformedTextFormat
1142+
}
1143+
1144+
transformedAvroFormat, err := expandPubsubTopicIngestionDataSourceSettingsCloudStorageAvroFormat(original["avro_format"], d, config)
1145+
if err != nil {
1146+
return nil, err
1147+
} else {
1148+
transformed["avroFormat"] = transformedAvroFormat
1149+
}
1150+
1151+
transformedPubsubAvroFormat, err := expandPubsubTopicIngestionDataSourceSettingsCloudStoragePubsubAvroFormat(original["pubsub_avro_format"], d, config)
1152+
if err != nil {
1153+
return nil, err
1154+
} else {
1155+
transformed["pubsubAvroFormat"] = transformedPubsubAvroFormat
1156+
}
1157+
1158+
transformedMinimumObjectCreateTime, err := expandPubsubTopicIngestionDataSourceSettingsCloudStorageMinimumObjectCreateTime(original["minimum_object_create_time"], d, config)
1159+
if err != nil {
1160+
return nil, err
1161+
} else if val := reflect.ValueOf(transformedMinimumObjectCreateTime); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1162+
transformed["minimumObjectCreateTime"] = transformedMinimumObjectCreateTime
1163+
}
1164+
1165+
transformedMatchGlob, err := expandPubsubTopicIngestionDataSourceSettingsCloudStorageMatchGlob(original["match_glob"], d, config)
1166+
if err != nil {
1167+
return nil, err
1168+
} else if val := reflect.ValueOf(transformedMatchGlob); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1169+
transformed["matchGlob"] = transformedMatchGlob
1170+
}
1171+
1172+
return transformed, nil
1173+
}
1174+
1175+
func expandPubsubTopicIngestionDataSourceSettingsCloudStorageBucket(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1176+
return v, nil
1177+
}
1178+
1179+
func expandPubsubTopicIngestionDataSourceSettingsCloudStorageTextFormat(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1180+
l := v.([]interface{})
1181+
if len(l) == 0 || l[0] == nil {
1182+
return nil, nil
1183+
}
1184+
raw := l[0]
1185+
original := raw.(map[string]interface{})
1186+
transformed := make(map[string]interface{})
1187+
1188+
transformedDelimiter, err := expandPubsubTopicIngestionDataSourceSettingsCloudStorageTextFormatDelimiter(original["delimiter"], d, config)
1189+
if err != nil {
1190+
return nil, err
1191+
} else if val := reflect.ValueOf(transformedDelimiter); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1192+
transformed["delimiter"] = transformedDelimiter
1193+
}
1194+
1195+
return transformed, nil
1196+
}
1197+
1198+
func expandPubsubTopicIngestionDataSourceSettingsCloudStorageTextFormatDelimiter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1199+
return v, nil
1200+
}
1201+
1202+
func expandPubsubTopicIngestionDataSourceSettingsCloudStorageAvroFormat(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1203+
l := v.([]interface{})
1204+
if len(l) == 0 {
1205+
return nil, nil
1206+
}
1207+
1208+
if l[0] == nil {
1209+
transformed := make(map[string]interface{})
1210+
return transformed, nil
1211+
}
1212+
transformed := make(map[string]interface{})
1213+
1214+
return transformed, nil
1215+
}
1216+
1217+
func expandPubsubTopicIngestionDataSourceSettingsCloudStoragePubsubAvroFormat(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1218+
l := v.([]interface{})
1219+
if len(l) == 0 {
1220+
return nil, nil
1221+
}
1222+
1223+
if l[0] == nil {
1224+
transformed := make(map[string]interface{})
1225+
return transformed, nil
1226+
}
1227+
transformed := make(map[string]interface{})
1228+
1229+
return transformed, nil
1230+
}
1231+
1232+
func expandPubsubTopicIngestionDataSourceSettingsCloudStorageMinimumObjectCreateTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1233+
return v, nil
1234+
}
1235+
1236+
func expandPubsubTopicIngestionDataSourceSettingsCloudStorageMatchGlob(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1237+
return v, nil
1238+
}
1239+
1240+
func expandPubsubTopicIngestionDataSourceSettingsPlatformLogsSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1241+
l := v.([]interface{})
1242+
if len(l) == 0 || l[0] == nil {
1243+
return nil, nil
1244+
}
1245+
raw := l[0]
1246+
original := raw.(map[string]interface{})
1247+
transformed := make(map[string]interface{})
1248+
1249+
transformedSeverity, err := expandPubsubTopicIngestionDataSourceSettingsPlatformLogsSettingsSeverity(original["severity"], d, config)
1250+
if err != nil {
1251+
return nil, err
1252+
} else if val := reflect.ValueOf(transformedSeverity); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1253+
transformed["severity"] = transformedSeverity
1254+
}
1255+
1256+
return transformed, nil
1257+
}
1258+
1259+
func expandPubsubTopicIngestionDataSourceSettingsPlatformLogsSettingsSeverity(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1260+
return v, nil
1261+
}
1262+
9211263
func expandPubsubTopicEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
9221264
if v == nil {
9231265
return map[string]string{}, nil

0 commit comments

Comments
 (0)