Skip to content

Commit 02e186f

Browse files
omerdemirokactions-user
authored andcommitted
feat: support logging api in gcp dynamic adapters (#1833)
# Add logging API to dynamic adapters Add adapter meta and terraform mappings for the following types to dynamic adapters: - [x] [logging.googleapis.com/LogSink](http://logging.googleapis.com/LogSink) (Order: 25, Weight: 20.00) - [X] [logging.googleapis.com/LogBucket](http://logging.googleapis.com/LogBucket) (Order: 28, Weight: 17.86) - [X] [logging.googleapis.com/Link](http://logging.googleapis.com/Link) (Order: 40, Weight: 12.50) - [X] [logging.googleapis.com/SavedQuery](http://logging.googleapis.com/SavedQuery) (Order: 41, Weight: 12.20) GitOrigin-RevId: 50df95bb6e7ab0a3753eaa06820ee93c302ac6e9
1 parent 49598c6 commit 02e186f

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

sources/gcp/dynamic/terraform-mappings.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,24 @@ var SDPAssetTypeToTerraformMappings = map[shared.ItemType]TerraformMapping{
179179
gcpshared.IAMRole: {
180180
Description: "There is no terraform resource for this type.",
181181
},
182+
gcpshared.LoggingBucket: {
183+
Description: "There is no terraform resource for this type.",
184+
},
185+
gcpshared.LoggingLink: {
186+
Description: "There is no terraform resource for this type.",
187+
},
188+
gcpshared.LoggingSavedQuery: {
189+
Description: "There is no terraform resource for this type.",
190+
},
191+
gcpshared.LoggingSink: {
192+
Reference: "https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/logging_project_sink",
193+
Mappings: []*sdp.TerraformMapping{
194+
{
195+
TerraformMethod: sdp.QueryMethod_GET,
196+
TerraformQueryMap: "google_logging_project_sink.name",
197+
},
198+
},
199+
},
182200
gcpshared.MonitoringCustomDashboard: {
183201
Reference: "https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_dashboard",
184202
Description: "id => projects/{{project}}/dashboards/{{dashboard_id}}",

sources/gcp/shared/adapter-meta.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,58 @@ var SDPAssetTypeToAdapterMeta = map[shared.ItemType]AdapterMeta{
585585
ListEndpointFunc: projectLevelListFunc("https://iam.googleapis.com/v1/projects/%s/roles"),
586586
UniqueAttributeKeys: []string{"roles"},
587587
},
588+
LoggingBucket: {
589+
SDPAdapterCategory: sdp.AdapterCategory_ADAPTER_CATEGORY_OBSERVABILITY,
590+
Scope: ScopeProject,
591+
// Reference: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.locations.buckets/get
592+
// GET https://logging.googleapis.com/v2/projects/*/locations/*/buckets/*
593+
// IAM permissions: logging.buckets.get
594+
GetEndpointBaseURLFunc: projectLevelEndpointFuncWithTwoQueries("https://logging.googleapis.com/v2/projects/%s/locations/%s/buckets/%s"),
595+
// Reference: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.locations.buckets/list
596+
// GET https://logging.googleapis.com/v2/projects/*/locations/*/buckets
597+
// IAM permissions: logging.buckets.list
598+
SearchEndpointFunc: projectLevelEndpointFuncWithSingleQuery("https://logging.googleapis.com/v2/projects/%s/locations/%s/buckets"),
599+
UniqueAttributeKeys: []string{"locations", "buckets"},
600+
},
601+
LoggingLink: {
602+
SDPAdapterCategory: sdp.AdapterCategory_ADAPTER_CATEGORY_OBSERVABILITY,
603+
Scope: ScopeProject,
604+
// Reference: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.locations.buckets.links/get
605+
// GET https://logging.googleapis.com/v2/projects/*/locations/*/buckets/*/links/*
606+
// IAM permissions: logging.links.get
607+
GetEndpointBaseURLFunc: projectLevelEndpointFuncWithThreeQueries("https://logging.googleapis.com/v2/projects/%s/locations/%s/buckets/%s/links/%s"),
608+
// Reference: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.locations.buckets.links/list
609+
// GET https://logging.googleapis.com/v2/projects/*/locations/*/buckets/*/links
610+
// IAM permissions: logging.links.list
611+
SearchEndpointFunc: projectLevelEndpointFuncWithTwoQueries("https://logging.googleapis.com/v2/projects/%s/locations/%s/buckets/%s/links"),
612+
UniqueAttributeKeys: []string{"locations", "buckets", "links"},
613+
},
614+
LoggingSavedQuery: {
615+
SDPAdapterCategory: sdp.AdapterCategory_ADAPTER_CATEGORY_OBSERVABILITY,
616+
Scope: ScopeProject,
617+
// Reference: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.locations.savedQueries/get
618+
// GET https://logging.googleapis.com/v2/projects/*/locations/*/savedQueries/*
619+
// IAM permissions: logging.savedQueries.get
620+
GetEndpointBaseURLFunc: projectLevelEndpointFuncWithTwoQueries("https://logging.googleapis.com/v2/projects/%s/locations/%s/savedQueries/%s"),
621+
// Reference: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.locations.savedQueries/list
622+
// GET https://logging.googleapis.com/v2/projects/*/locations/*/savedQueries
623+
// IAM permissions: logging.savedQueries.list
624+
SearchEndpointFunc: projectLevelEndpointFuncWithSingleQuery("https://logging.googleapis.com/v2/projects/%s/locations/%s/savedQueries"),
625+
UniqueAttributeKeys: []string{"locations", "savedQueries"},
626+
},
627+
LoggingSink: {
628+
SDPAdapterCategory: sdp.AdapterCategory_ADAPTER_CATEGORY_OBSERVABILITY,
629+
Scope: ScopeProject,
630+
// Reference: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get
631+
// GET https://logging.googleapis.com/v2/projects/*/sinks/*
632+
// IAM permissions: logging.sinks.get
633+
GetEndpointBaseURLFunc: projectLevelEndpointFuncWithSingleQuery("https://logging.googleapis.com/v2/projects/%s/sinks/%s"),
634+
// Reference: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/list
635+
// GET https://logging.googleapis.com/v2/projects/*/sinks
636+
// IAM permissions: logging.sinks.list
637+
ListEndpointFunc: projectLevelListFunc("https://logging.googleapis.com/v2/projects/%s/sinks"),
638+
UniqueAttributeKeys: []string{"sinks"},
639+
},
588640
MonitoringCustomDashboard: {
589641
SDPAdapterCategory: sdp.AdapterCategory_ADAPTER_CATEGORY_OBSERVABILITY,
590642
Scope: ScopeProject,

sources/gcp/shared/item-types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,8 @@ var (
7373
DNSManagedZone = shared.NewItemType(GCP, DNS, ManagedZone)
7474
CloudBillingBillingInfo = shared.NewItemType(GCP, CloudBilling, BillingInfo)
7575
EssentialContactsContact = shared.NewItemType(GCP, EssentialContacts, Contact)
76+
LoggingSavedQuery = shared.NewItemType(GCP, Logging, SavedQuery)
77+
LoggingBucket = shared.NewItemType(GCP, Logging, Bucket)
78+
LoggingLink = shared.NewItemType(GCP, Logging, Link)
79+
LoggingSink = shared.NewItemType(GCP, Logging, Sink)
7680
)

sources/gcp/shared/models.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const (
3232
DNS shared.API = "dns"
3333
CloudBilling shared.API = "cloud-billing"
3434
EssentialContacts shared.API = "essential-contacts"
35+
Logging shared.API = "logging"
3536
)
3637

3738
// Resources
@@ -108,4 +109,7 @@ const (
108109
ManagedZone shared.Resource = "managed-zone"
109110
BillingInfo shared.Resource = "billing-info"
110111
Contact shared.Resource = "contact"
112+
SavedQuery shared.Resource = "saved-query"
113+
Link shared.Resource = "link"
114+
Sink shared.Resource = "sink"
111115
)

0 commit comments

Comments
 (0)