@@ -87,17 +87,17 @@ func (d *GoogleFirebaseWebAppConfigDataSource) Schema(ctx context.Context, req d
87
87
},
88
88
89
89
"location_id": schema.StringAttribute{
90
- Description: "The ID of the project's default GCP resource location. The location is one of the available GCP resource locations. " +
91
- "This field is omitted if the default GCP resource location has not been finalized yet. To set your project's " +
90
+ Description: "The ID of the project's default GCP resource location. The location is one of the available GCP resource locations. " +
91
+ "This field is omitted if the default GCP resource location has not been finalized yet. To set your project's " +
92
92
"default GCP resource location, call defaultLocation.finalize after you add Firebase services to your project.",
93
93
MarkdownDescription: "The ID of the project's default GCP resource location. The location is one of the available GCP resource locations. " +
94
- "This field is omitted if the default GCP resource location has not been finalized yet. To set your project's " +
94
+ "This field is omitted if the default GCP resource location has not been finalized yet. To set your project's " +
95
95
"default GCP resource location, call defaultLocation.finalize after you add Firebase services to your project.",
96
- Computed: true,
96
+ Computed: true,
97
97
},
98
98
99
99
"measurement_id": schema.StringAttribute{
100
- Description: "The unique Google-assigned identifier of the Google Analytics web stream associated with the Firebase Web App. " +
100
+ Description: "The unique Google-assigned identifier of the Google Analytics web stream associated with the Firebase Web App. " +
101
101
"Firebase SDKs use this ID to interact with Google Analytics APIs. " +
102
102
"This field is only present if the App is linked to a web stream in a Google Analytics App + Web property. " +
103
103
"Learn more about this ID and Google Analytics web streams in the Analytics documentation. " +
@@ -107,7 +107,7 @@ func (d *GoogleFirebaseWebAppConfigDataSource) Schema(ctx context.Context, req d
107
107
"This field is only present if the App is linked to a web stream in a Google Analytics App + Web property. " +
108
108
"Learn more about this ID and Google Analytics web streams in the Analytics documentation. " +
109
109
"To generate a measurementId and link the Web App with a Google Analytics web stream, call projects.addGoogleAnalytics.",
110
- Computed: true,
110
+ Computed: true,
111
111
},
112
112
113
113
"messaging_sender_id": schema.StringAttribute{
@@ -122,6 +122,7 @@ func (d *GoogleFirebaseWebAppConfigDataSource) Schema(ctx context.Context, req d
122
122
Computed: true,
123
123
},
124
124
125
+ // This is included for backwards compatibility with the original, SDK-implemented data source.
125
126
"id": schema.StringAttribute{
126
127
Description: "Firebase Web App Config identifier",
127
128
MarkdownDescription: "Firebase Web App Config identifier",
@@ -163,25 +164,24 @@ func (d *GoogleFirebaseWebAppConfigDataSource) Read(ctx context.Context, req dat
163
164
return
164
165
}
165
166
166
- d.client.UserAgent = fwtransport.GenerateFrameworkUserAgentString(metaData, d.client.UserAgent)
167
-
168
- client := firebase.NewProjectsWebAppsService(d.client)
169
-
170
167
// Read Terraform configuration data into the model
171
168
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
172
169
if resp.Diagnostics.HasError() {
173
170
return
174
171
}
175
172
173
+ // Use provider_meta to set User-Agent
174
+ d.client.UserAgent = fwtransport.GenerateFrameworkUserAgentString(metaData, d.client.UserAgent)
175
+
176
176
data.Project = fwresource.GetProjectFramework(data.Project, d.project, &resp.Diagnostics)
177
177
if resp.Diagnostics.HasError() {
178
178
return
179
179
}
180
180
181
+ // GET Request
182
+ service := firebase.NewProjectsWebAppsService(d.client)
181
183
appName := fmt.Sprintf("projects/%s/webApps/%s/config", data.Project.ValueString(), data.WebAppId.ValueString())
182
- data.Id = data.WebAppId
183
-
184
- clientResp, err := client.GetConfig(appName).Do()
184
+ clientResp, err := service.GetConfig(appName).Do()
185
185
if err != nil {
186
186
fwtransport.HandleDatasourceNotFoundError(ctx, err, &resp.State, fmt.Sprintf("dataSourceFirebaseWebAppConfig %q", data.WebAppId.ValueString()), &resp.Diagnostics)
187
187
if resp.Diagnostics.HasError() {
@@ -191,6 +191,8 @@ func (d *GoogleFirebaseWebAppConfigDataSource) Read(ctx context.Context, req dat
191
191
192
192
tflog.Trace(ctx, "read firebase web app config data source")
193
193
194
+ // Put data in model
195
+ data.Id = data.WebAppId
194
196
data.ApiKey = types.StringValue(clientResp.ApiKey)
195
197
data.AuthDomain = types.StringValue(clientResp.AuthDomain)
196
198
data.DatabaseUrl = types.StringValue(clientResp.DatabaseURL)
0 commit comments