Skip to content

Commit 7a41add

Browse files
Copilotmattdotmawasile
authored
Deprecate powerplatform_rest resource (#861)
* Initial plan * Initial plan for deprecating powerplatform_rest resource Co-authored-by: mattdot <266258+mattdot@users.noreply.github.com> * Add deprecation message to powerplatform_rest resource Co-authored-by: mattdot <266258+mattdot@users.noreply.github.com> * Update deprecation message to suggest opening GitHub issues Co-authored-by: mattdot <266258+mattdot@users.noreply.github.com> * Add changelog entry for powerplatform_rest deprecation Co-authored-by: mattdot <266258+mattdot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mattdot <266258+mattdot@users.noreply.github.com> Co-authored-by: Matt Dotson <mattdot@users.noreply.github.com> Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
1 parent ee28bd1 commit 7a41add

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
kind: deprecated
2+
body: Mark powerplatform_rest resource as deprecated. Known uses do not align with the intent of the resource. Please consider using specific resources for your use case, or opening a GitHub issue requesting a new resource for your use case.
3+
custom:
4+
Issue: 860

internal/services/rest/resource_rest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func (r *DataverseWebApiResource) Schema(ctx context.Context, req resource.Schem
7676
ctx, exitContext := helpers.EnterRequestContext(ctx, r.TypeInfo, req)
7777
defer exitContext()
7878
resp.Schema = schema.Schema{
79+
DeprecationMessage: "This resource is deprecated. Please consider using specific resources for your use case, or opening a GitHub issue requesting a new resource for your use case.",
7980
MarkdownDescription: `Resource to execute web api requests. There are four distinct operations, that you can define independently. The HTTP response' body of the operation, that was called as last, will be returned in 'output.body' \n\n:
8081
* Create: will be called once during the lifecycle of the resource (first 'terraform apply')
8182
* Read: terraform will call this operation every time during 'plan' and 'apply' to get the current state of the resource

internal/services/rest/resource_rest_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,44 @@ func TestUnitTestRest_Validate_Create(t *testing.T) {
276276
},
277277
})
278278
}
279+
280+
func TestUnitTestRest_Deprecation_Still_Works(t *testing.T) {
281+
// This test verifies that the deprecated resource still functions correctly
282+
// The deprecation warning is handled by the framework and doesn't break functionality
283+
httpmock.Activate()
284+
defer httpmock.DeactivateAndReset()
285+
286+
httpmock.RegisterResponder("GET", `https://api.bap.microsoft.com/providers/Microsoft.BusinessAppPlatform/scopes/admin/environments/00000000-0000-0000-0000-000000000001?api-version=2023-06-01`,
287+
func(req *http.Request) (*http.Response, error) {
288+
return httpmock.NewStringResponse(http.StatusOK, httpmock.File("tests/resource/Web_Api_Validate_Create/get_environment_00000000-0000-0000-0000-000000000001.json").String()), nil
289+
})
290+
291+
httpmock.RegisterResponder("POST", `https://00000000-0000-0000-0000-000000000001.crm4.dynamics.com/api/data/v9.2/accounts?$select=name,accountid`,
292+
func(req *http.Request) (*http.Response, error) {
293+
return httpmock.NewStringResponse(http.StatusCreated, httpmock.File("tests/resource/Web_Api_Validate_Create/post_account.json").String()), nil
294+
})
295+
296+
resource.Test(t, resource.TestCase{
297+
IsUnitTest: true,
298+
ProtoV6ProviderFactories: mocks.TestUnitTestProtoV6ProviderFactories,
299+
Steps: []resource.TestStep{
300+
{
301+
Config: `
302+
resource "powerplatform_rest" "deprecated_test" {
303+
create = {
304+
scope = "https://00000000-0000-0000-0000-000000000001.crm4.dynamics.com/.default"
305+
url = "https://00000000-0000-0000-0000-000000000001.crm4.dynamics.com/api/data/v9.2/accounts?$select=name,accountid"
306+
method = "POST"
307+
body = jsonencode({
308+
"accountid" : "00000000-0000-0000-0000-000000000001",
309+
"name" : "powerplatform_rest"
310+
})
311+
}
312+
}`,
313+
Check: resource.ComposeAggregateTestCheckFunc(
314+
resource.TestCheckResourceAttr("powerplatform_rest.deprecated_test", "output.body", httpmock.File("tests/resource/Web_Api_Validate_Create/post_account.json").String()),
315+
),
316+
},
317+
},
318+
})
319+
}

0 commit comments

Comments
 (0)