Skip to content

Commit

Permalink
Adding powerplatform_billing policy_environments datasource & resorce (
Browse files Browse the repository at this point in the history
…#132)

* main merge

* Squashed commit of the following:

commit 0d826b7
Author: mawasile <[email protected]>
Date:   Wed Nov 15 19:10:04 2023 +0100

    Implemented PowerPlatform Managed Environment Resource (#110)

    * Squashed commit of the following:

    commit 6ba7268
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Fri Oct 20 10:38:39 2023 +0200

        moving logic to services

    commit 72e403b
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Thu Oct 19 10:05:16 2023 +0200

        updating go-crypto lib

    * adding managed env api and empty resource object (work in progress)

    * Squashed commit of the following:

    commit 88a881e
    Author: Eduardo Sanchez <[email protected]>
    Date:   Tue Oct 24 00:20:45 2023 -0600

        Edsanche/105 git connectivity from within the dev container (#108)

        * Update Note for set Git Credentials.

        * Updating docs.

        * Updating Git credentials section.

        * Update DEVELOPER.md If you logging to docker container.

        Co-authored-by: mawasile <[email protected]>

        * Adding Suggestion and fixing MD linting.

        ---------

        Co-authored-by: mawasile <[email protected]>

    * adding crud operations

    * adding operation status checking

    * added operation status checks

    * adding acceptance tests

    * adding example tf files

    * generating docs

    * Updating WIP files for managed environment tests.

    * contnue wit tests development.

    * Making the Unit test work (WIP).

    * TEsting unit test for managed env.

    * adding plan modifiers to tenant settings

    * creating TestUnitManagedEnvironmentsResource_Validate_Create(

    * Creating: TestUnitManagedEnvironmentsResource_Validate_Update.

    * Updating gitignore and docs.

    * Adding "managed_environmen" to provider_test.go

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create/get_lifecycle.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Force_Recreate/get_lifecycle_00000000-0000-0000-0000-000000000001.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create/get_environment_00000000-0000-0000-0000-000000000001.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create/get_environment_00000000-0000-0000-0000-000000000001.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Force_Recreate/get_environment_00000000-0000-0000-0000-000000000001.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Force_Recreate/get_environment_00000000-0000-0000-0000-000000000001.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Update/get_environment_create_response.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Force_Recreate/get_lifecycle_00000000-0000-0000-0000-000000000002.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Force_Recreate/get_lifecycle_00000000-0000-0000-0000-000000000003.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Force_Recreate/get_lifecycle_00000000-0000-0000-0000-000000000005.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Update/get_environment_0.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Update/get_environment_0.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Update/get_environment_1.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Update/get_environment_1.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Update/get_environments_1.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Update/get_environments_1.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/resource/Validate_Create_And_Update/get_lifecycle.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/datasource/Validate_Read/get_environment_00000000-0000-0000-0000-000000000001.json

    Co-authored-by: mawasile <[email protected]>

    * Update internal/powerplatform/services/managed_environment/tests/datasource/Validate_Read/get_environment_00000000-0000-0000-0000-000000000001.json

    Co-authored-by: mawasile <[email protected]>

    * WIP Creating TestUnitManagedEnvironmentsResource_Validate_Update

    * Creating test and files for "ExtendedGovernanceConfiguration".

    * Eliminating not required files.

    * fixing api_managed_environment.

    * Applying suggestions and comments.

    * Changing test name.

    * Squashed commit of the following:

    commit bc61b64
    Merge: bae0886 205c9ea
    Author: mawasile <[email protected]>
    Date:   Wed Nov 15 10:27:30 2023 +0100

        Merge branch 'main' into mattdot/44-billing-policies-and-assigning-environments

    commit bae0886
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Wed Nov 15 09:09:17 2023 +0000

        main merge

    commit 9d63031
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Wed Nov 15 09:08:43 2023 +0000

        Squashed commit of the following:

        commit 205c9ea
        Author: Engin Polat <[email protected]>
        Date:   Mon Nov 13 00:29:56 2023 -0800

            simplifying and fixing credentials set logic (#119)

            * simplifying and fixing credentials set logic

            * adding headers support to api calls

            ---------

            Co-authored-by: mawasile <[email protected]>

        commit 3f61156
        Author: Engin Polat <[email protected]>
        Date:   Fri Nov 10 06:49:21 2023 -0800

            username and password authentication support to powerplatform api calls (#122)

            * simplifying and fixing credentials set logic

            * adding headers support to api calls

            * changing api helper signatures to support passing all credentials information

            * adding username and password authentication support to powerplatform api calls

        commit 33a5098
        Author: Engin Polat <[email protected]>
        Date:   Thu Nov 9 21:13:46 2023 -0800

            changing api helper signatures (#121)

            * simplifying and fixing credentials set logic

            * adding headers support to api calls

            * changing api helper signatures to support passing all credentials information

            * fixing failing build

        commit 16197e6
        Author: mawasile <[email protected]>
        Date:   Tue Oct 31 07:38:33 2023 +0100

            Mawasile/90 resource powerplatform tenant settings (#112)

            * adding tenant settings data source

            * adding working tenant settings

            * adding user docs

            * adding unit test for datasource tenant settings

            * adding test for resource tenant settings

        commit 160ad03
        Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Date:   Mon Oct 30 16:58:12 2023 -0700

            Bump github.com/hashicorp/terraform-plugin-framework from 1.4.1 to 1.4.2 (#113)

            Bumps [github.com/hashicorp/terraform-plugin-framework](https://github.com/hashicorp/terraform-plugin-framework) from 1.4.1 to 1.4.2.
            - [Release notes](https://github.com/hashicorp/terraform-plugin-framework/releases)
            - [Changelog](https://github.com/hashicorp/terraform-plugin-framework/blob/main/CHANGELOG.md)
            - [Commits](hashicorp/terraform-plugin-framework@v1.4.1...v1.4.2)

            ---
            updated-dependencies:
            - dependency-name: github.com/hashicorp/terraform-plugin-framework
              dependency-type: direct:production
              update-type: version-update:semver-patch
            ...

            Signed-off-by: dependabot[bot] <[email protected]>
            Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    commit 216b6ef
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Wed Nov 15 08:57:09 2023 +0000

        adding tests for billing policy datasource

    commit c721f15
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Wed Nov 15 08:10:41 2023 +0000

        Add new billing policies data source

    commit 1dee97b
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Wed Nov 15 06:41:15 2023 +0000

        adding example resource file for billing policy create

    commit 411ee61
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Tue Nov 14 13:58:46 2023 +0000

        adding tests for billing policy

    commit 90ee364
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Tue Nov 14 07:42:43 2023 +0000

        Billing policy logic

    commit f770e19
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Mon Nov 13 09:47:19 2023 +0100

        adding clientid to ppapi auth user/pass flow

    commit c08b185
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Mon Nov 13 09:45:21 2023 +0100

        Squashed commit of the following:

        commit 205c9ea
        Author: Engin Polat <[email protected]>
        Date:   Mon Nov 13 00:29:56 2023 -0800

            simplifying and fixing credentials set logic (#119)

            * simplifying and fixing credentials set logic

            * adding headers support to api calls

            ---------

            Co-authored-by: mawasile <[email protected]>

        commit 3f61156
        Author: Engin Polat <[email protected]>
        Date:   Fri Nov 10 06:49:21 2023 -0800

            username and password authentication support to powerplatform api calls (#122)

            * simplifying and fixing credentials set logic

            * adding headers support to api calls

            * changing api helper signatures to support passing all credentials information

            * adding username and password authentication support to powerplatform api calls

        commit 33a5098
        Author: Engin Polat <[email protected]>
        Date:   Thu Nov 9 21:13:46 2023 -0800

            changing api helper signatures (#121)

            * simplifying and fixing credentials set logic

            * adding headers support to api calls

            * changing api helper signatures to support passing all credentials information

            * fixing failing build

        commit 16197e6
        Author: mawasile <[email protected]>
        Date:   Tue Oct 31 07:38:33 2023 +0100

            Mawasile/90 resource powerplatform tenant settings (#112)

            * adding tenant settings data source

            * adding working tenant settings

            * adding user docs

            * adding unit test for datasource tenant settings

            * adding test for resource tenant settings

        commit 160ad03
        Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Date:   Mon Oct 30 16:58:12 2023 -0700

            Bump github.com/hashicorp/terraform-plugin-framework from 1.4.1 to 1.4.2 (#113)

            Bumps [github.com/hashicorp/terraform-plugin-framework](https://github.com/hashicorp/terraform-plugin-framework) from 1.4.1 to 1.4.2.
            - [Release notes](https://github.com/hashicorp/terraform-plugin-framework/releases)
            - [Changelog](https://github.com/hashicorp/terraform-plugin-framework/blob/main/CHANGELOG.md)
            - [Commits](hashicorp/terraform-plugin-framework@v1.4.1...v1.4.2)

            ---
            updated-dependencies:
            - dependency-name: github.com/hashicorp/terraform-plugin-framework
              dependency-type: direct:production
              update-type: version-update:semver-patch
            ...

            Signed-off-by: dependabot[bot] <[email protected]>
            Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    commit 4f86f44
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Mon Nov 13 06:50:03 2023 +0000

        WIP

    commit bf99839
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Thu Nov 2 08:24:20 2023 +0100

        work in progress

    commit d20fed2
    Author: Mateusz Wasilewski <[email protected]>
    Date:   Tue Oct 31 09:24:49 2023 +0100

        Squashed commit of the following:

        commit 16197e6
        Author: mawasile <[email protected]>
        Date:   Tue Oct 31 07:38:33 2023 +0100

            Mawasile/90 resource powerplatform tenant settings (#112)

            * adding tenant settings data source

            * adding working tenant settings

            * adding user docs

            * adding unit test for datasource tenant settings

            * adding test for resource tenant settings

        commit 160ad03
        Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Date:   Mon Oct 30 16:58:12 2023 -0700

            Bump github.com/hashicorp/terraform-plugin-framework from 1.4.1 to 1.4.2 (#113)

            Bumps [github.com/hashicorp/terraform-plugin-framework](https://github.com/hashicorp/terraform-plugin-framework) from 1.4.1 to 1.4.2.
            - [Release notes](https://github.com/hashicorp/terraform-plugin-framework/releases)
            - [Changelog](https://github.com/hashicorp/terraform-plugin-framework/blob/main/CHANGELOG.md)
            - [Commits](hashicorp/terraform-plugin-framework@v1.4.1...v1.4.2)

            ---
            updated-dependencies:
            - dependency-name: github.com/hashicorp/terraform-plugin-framework
              dependency-type: direct:production
              update-type: version-update:semver-patch
            ...

            Signed-off-by: dependabot[bot] <[email protected]>
            Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    commit b291188
    Author: Matt Dotson <[email protected]>
    Date:   Tue Oct 31 00:49:18 2023 -0700

        committing latest

    commit cd8630b
    Merge: bd717ff beb1966
    Author: Matt Dotson <[email protected]>
    Date:   Thu Oct 26 10:43:28 2023 -0700

        Merge branch 'main' into mattdot/44-billing-policies-and-assigning-environments

    commit bd717ff
    Author: Matt Dotson <[email protected]>
    Date:   Thu Oct 26 10:40:36 2023 -0700

        committing progress before merging main

    commit bcec9f4
    Author: Matt Dotson <[email protected]>
    Date:   Wed Oct 11 10:46:27 2023 -0700

        updates on billing policies

    commit 4cd05db
    Merge: dbc175b 4ba0a8f
    Author: Matt Dotson <[email protected]>
    Date:   Tue Sep 26 12:16:23 2023 -0700

        Merge branch 'main' into mattdot/44-billing-policies-and-assigning-environments

    commit dbc175b
    Author: Matt Dotson <[email protected]>
    Date:   Thu Sep 21 11:14:45 2023 -0700

        In progress billing policy

    * Update provider_test.go

    ---------

    Co-authored-by: Eduardo Sanchez <[email protected]>

* adding billing policy environment implementation

* adding billing policy environments resource & datasource

* adding test for billing policy environemts datasource

* adding test for billing policy environments

* Update powerplatform_billing_policy_environment
unit tests configuration
  • Loading branch information
mawasile authored Nov 29, 2023
1 parent 4e063b8 commit 066a4ec
Show file tree
Hide file tree
Showing 53 changed files with 1,151 additions and 33 deletions.
69 changes: 69 additions & 0 deletions docs/data-sources/billing_policies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "powerplatform_billing_policies Data Source - powerplatform"
subcategory: ""
description: |-
Fetches the list of billing policies in a tenant
---

# powerplatform_billing_policies (Data Source)

Fetches the list of billing policies in a tenant

## Example Usage

```terraform
terraform {
required_providers {
powerplatform = {
version = "0.2"
source = "microsoft/power-platform"
}
}
}
provider "powerplatform" {
client_id = var.client_id
secret = var.secret
tenant_id = var.tenant_id
}
data "powerplatform_billing_policies" "all_policies" {}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Read-Only

- `billing_policies` (Attributes List) [Power Platform Billing Policy](https://learn.microsoft.com/en-us/rest/api/power-platform/licensing/billing-policy/get-billing-policy#billingpolicyresponsemodel) (see [below for nested schema](#nestedatt--billing_policies))
- `id` (Number) Placeholder identifier attribute

<a id="nestedatt--billing_policies"></a>
### Nested Schema for `billing_policies`

Required:

- `billing_instrument` (Attributes) The billing instrument of the billing policy (see [below for nested schema](#nestedatt--billing_policies--billing_instrument))
- `location` (String) The location of the billing policy
- `name` (String) The name of the billing policy

Optional:

- `status` (String) The status of the billing policy (Enabled, Disabled)

Read-Only:

- `id` (String) The id of the billing policy

<a id="nestedatt--billing_policies--billing_instrument"></a>
### Nested Schema for `billing_policies.billing_instrument`

Required:

- `resource_group` (String) The resource group of the billing instrument
- `subscription_id` (String) The subscription id of the billing instrument

Read-Only:

- `id` (String) The id of the billing instrument
45 changes: 45 additions & 0 deletions docs/data-sources/billing_policies_environments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "powerplatform_billing_policies_environments Data Source - powerplatform"
subcategory: ""
description: |-
Fetches the list of billing policies in a tenant
---

# powerplatform_billing_policies_environments (Data Source)

Fetches the list of billing policies in a tenant

## Example Usage

```terraform
terraform {
required_providers {
powerplatform = {
version = "0.2"
source = "microsoft/power-platform"
}
}
}
provider "powerplatform" {
client_id = var.client_id
secret = var.secret
tenant_id = var.tenant_id
}
data "powerplatform_billing_policies_environments" "all_pay_as_you_go_policy_envs" {
billing_policy_id = "00000000-0000-0000-0000-000000000000"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `billing_policy_id` (String) The id of the billing policy

### Read-Only

- `environments` (Set of String) The environments associated with the billing policy
69 changes: 69 additions & 0 deletions docs/resources/billing_policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "powerplatform_billing_policy Resource - powerplatform"
subcategory: ""
description: |-
Power Platform Billing Policy https://learn.microsoft.com/en-us/rest/api/power-platform/licensing/billing-policy/get-billing-policy#billingpolicyresponsemodel
---

# powerplatform_billing_policy (Resource)

[Power Platform Billing Policy](https://learn.microsoft.com/en-us/rest/api/power-platform/licensing/billing-policy/get-billing-policy#billingpolicyresponsemodel)

## Example Usage

```terraform
terraform {
required_providers {
powerplatform = {
version = "0.2"
source = "microsoft/power-platform"
}
}
}
provider "powerplatform" {
username = var.username
password = var.password
tenant_id = var.tenant_id
}
resource "powerplatform_billing_policy" "pay_as_you_go" {
name = "payAsYouGoBillingPolicyExample"
location = "europe"
status = "Enabled"
billing_instrument = {
resource_group = "resource_group_name"
subscription_id = "00000000-0000-0000-0000-000000000000"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `billing_instrument` (Attributes) The billing instrument of the billing policy (see [below for nested schema](#nestedatt--billing_instrument))
- `location` (String) The location of the billing policy
- `name` (String) The name of the billing policy

### Optional

- `status` (String) The status of the billing policy (Enabled, Disabled)

### Read-Only

- `id` (String) The id of the billing policy

<a id="nestedatt--billing_instrument"></a>
### Nested Schema for `billing_instrument`

Required:

- `resource_group` (String) The resource group of the billing instrument
- `subscription_id` (String) The subscription id of the billing instrument

Read-Only:

- `id` (String) The id of the billing instrument
43 changes: 43 additions & 0 deletions docs/resources/billing_policy_environment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "powerplatform_billing_policy_environment Resource - powerplatform"
subcategory: ""
description: |-
Power Platform Billing Policy Environments
---

# powerplatform_billing_policy_environment (Resource)

Power Platform Billing Policy Environments

## Example Usage

```terraform
terraform {
required_providers {
powerplatform = {
version = "0.2"
source = "microsoft/power-platform"
}
}
}
provider "powerplatform" {
username = var.username
password = var.password
tenant_id = var.tenant_id
}
resource "powerplatform_billing_policy_environment" "pay_as_you_go_policy_envs" {
billing_policy_id = "00000000-0000-0000-0000-000000000000"
environments = ["00000000-0000-0000-0000-000000000001", "00000000-0000-0000-0000-000000000002"]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `billing_policy_id` (String) The id of the billing policy
- `environments` (Set of String) The environments associated with the billing policy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "all_connectors" {
output "all_billing_policies" {
description = "All Billing Policies"
value = data.powerplatform_billing_policies.all_policies
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
terraform {
required_providers {
powerplatform = {
version = "0.2"
source = "microsoft/power-platform"
}
}
}

provider "powerplatform" {
client_id = var.client_id
secret = var.secret
tenant_id = var.tenant_id
}

data "powerplatform_billing_policies_environments" "all_pay_as_you_go_policy_envs" {
billing_policy_id = "00000000-0000-0000-0000-000000000000"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "all_policy_environments" {
description = "All Billing Policies for an Environment"
value = data.powerplatform_billing_policies_environments.all_pay_as_you_go_policy_envs
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
variable "client_id" {
description = "The client ID of the of the service principal"
type = string

}
variable "secret" {
description = "The client secret of the service principal"
sensitive = true
type = string
}
variable "tenant_id" {
description = "The tenant id of the AAD tenant"
type = string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "policy_name" {
description = "Unique Id of the Power Platform Billing Policy"
value = powerplatform_billing_policy_environment.pay_as_you_go_policy_envs.billing_policy_id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
terraform {
required_providers {
powerplatform = {
version = "0.2"
source = "microsoft/power-platform"
}
}
}

provider "powerplatform" {
username = var.username
password = var.password
tenant_id = var.tenant_id
}

resource "powerplatform_billing_policy_environment" "pay_as_you_go_policy_envs" {
billing_policy_id = "00000000-0000-0000-0000-000000000000"
environments = ["00000000-0000-0000-0000-000000000001", "00000000-0000-0000-0000-000000000002"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variable "username" {
default = "[email protected]"
description = "The username of the Power Platform API in user@domain format"
type = string

}
variable "password" {
default = "<my_passoword>"
description = "The password of the Power Platform API user"
sensitive = true
type = string
}
variable "tenant_id" {
default = "<my_tenant_id>"
description = "The tenant id of the AAD tenant"
type = string
}
21 changes: 0 additions & 21 deletions internal/powerplatform/api/api_powerplatform.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package powerplatform
import (
"context"
"net/http"
"net/url"

common "github.com/microsoft/terraform-provider-power-platform/internal/powerplatform/common"
models "github.com/microsoft/terraform-provider-power-platform/internal/powerplatform/models"
)

type PowerPlatformClientApi struct {
Expand All @@ -32,22 +30,3 @@ func (client *PowerPlatformClientApi) Execute(ctx context.Context, method string
}
return client.baseApi.ExecuteBase(ctx, token, method, url, headers, body, acceptableStatusCodes, responseObj)
}

func (client *PowerPlatformClientApi) GetBillingPolicies(ctx context.Context) ([]models.BillingPolicyDto, error) {
apiUrl := &url.URL{
Scheme: "https",
Host: client.baseApi.GetConfig().Urls.PowerPlatformUrl,
Path: "/licensing/billingPolicies",
}
values := url.Values{}
values.Add("api-version", "2022-03-01-preview")
apiUrl.RawQuery = values.Encode()

billingPolicies := models.BillingPolicyDtoArray{}
_, err := client.Execute(ctx, "GET", apiUrl.String(), nil, nil, []int{http.StatusOK}, &billingPolicies)
if err != nil {
return nil, err
}

return billingPolicies.Value, nil
}
Loading

0 comments on commit 066a4ec

Please sign in to comment.