@@ -75,6 +75,13 @@ func tableGcpProject(_ context.Context) *plugin.Table {
75
75
Hydrate : getProjectAncestors ,
76
76
Transform : transform .FromValue (),
77
77
},
78
+ {
79
+ Name : "billing_information" ,
80
+ Description : "The billing information of the project." ,
81
+ Type : proto .ColumnType_JSON ,
82
+ Hydrate : getProjectBillingInfo ,
83
+ Transform : transform .FromValue (),
84
+ },
78
85
79
86
// Steampipe standard columns
80
87
{
@@ -188,6 +195,28 @@ func getProjectAncestors(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd
188
195
return resp .Ancestor , nil
189
196
}
190
197
198
+ func getProjectBillingInfo (ctx context.Context , d * plugin.QueryData , h * plugin.HydrateData ) (interface {}, error ) {
199
+ // Create Service Connection
200
+ service , err := BillingService (ctx , d )
201
+ if err != nil {
202
+ plugin .Logger (ctx ).Error ("gcp_project.getProjectBillingInformation" , "connection_error" , err )
203
+ return nil , err
204
+ }
205
+
206
+ // Get project details
207
+ projectId := h .Item .(* cloudresourcemanager.Project ).ProjectId
208
+
209
+ resp , err := service .Projects .GetBillingInfo ("projects/" + projectId ).Do ()
210
+ if err != nil {
211
+ if strings .Contains (err .Error (), "404" ) {
212
+ return nil , nil
213
+ }
214
+ plugin .Logger (ctx ).Error ("gcp_project.getProjectBillingInformation" , "api_err" , err )
215
+ return nil , err
216
+ }
217
+ return resp , nil
218
+ }
219
+
191
220
func projectSelfLink (_ context.Context , d * transform.TransformData ) (interface {}, error ) {
192
221
data := d .HydrateItem .(* cloudresourcemanager.Project )
193
222
selfLink := "https://cloudresourcemanager.googleapis.com/v1/projects/" + data .Name
0 commit comments