microsoft / terraform-provider-power-platform

Power Platform Terraform Provider
https://registry.terraform.io/providers/microsoft/power-platform/latest/docs
MIT License
35 stars 13 forks source link

`powerplatform_tenant_capacity` Data Source #400

Closed mattdot closed 2 months ago

mattdot commented 2 months ago

Description

Provide a data source to retrieve tenant capacity data.

Resource

Potential Terraform Configuration

# Sample Terraform config that describes how the new resource might look.

data "powerplatform_tenant_capacity" "example_capacity" {
  tenant_id = "" #required
  capacity_type = "value1" #optional
}

API

https://licensing.powerplatform.microsoft.com/v0.1-alpha/tenants/4481d6dc-0f72-4841-a3a9-0000000000000/TenantCapacity

Not everything from the json needs to be exposed. May exclude capacityEntitlements and overflowCapacity from initial implementation. Can add those as an enhancement if we have future requests for this capability.

{
    "tenantId": "4481d6dc-0f72-4841-a3a9-0000000000000",
    "licenseModelType": "StorageDriven",
    "capacitySummary": {
        "status": "Available",
        "statusMessage": "You have available capacity across all storage types.",
        "statusMessageCode": "AllCapacityAvailable",
        "finOpsStatus": "None",
        "finOpsStatusMessage": "Finance and Operations Storage Capacity Usage reporting is in preview and for information only.",
        "finOpsStatusMessageCode": "FinOpsNotAvailable"
    },
    "tenantCapacities": [
        {
            "capacityType": "Database",
            "capacityUnits": "MB",
            "totalCapacity": 11264.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 2100.8356,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "Available",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "Database",
                    "capacitySubType": "DatabaseBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                },
                {
                    "capacityType": "Database",
                    "capacitySubType": "DatabaseIncremental",
                    "totalCapacity": 0.0,
                    "licenses": []
                },
                {
                    "capacityType": "Database",
                    "capacitySubType": "DatabaseAddOn",
                    "totalCapacity": 11264.0,
                    "licenses": [
                        {
                            "entitlementCode": "CDS_DB_Capacity",
                            "displayName": "Database capacity",
                            "servicePlanId": "360bcc37-0c11-4264-8eed-000000000000",
                            "skuId": "e612d426-6bc3-4181-9658-000000000000",
                            "paid": {
                                "enabled": 11,
                                "warning": 0,
                                "suspended": 0
                            },
                            "trial": {
                                "enabled": 0,
                                "warning": 0,
                                "suspended": 0
                            },
                            "totalCapacity": 11264.0,
                            "capabilityStatus": "Enabled"
                        }
                    ]
                }
            ]
        },
        {
            "capacityType": "File",
            "capacityUnits": "MB",
            "totalCapacity": 0.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 2646.107,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "Available",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "File",
                    "capacitySubType": "FileBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                },
                {
                    "capacityType": "File",
                    "capacitySubType": "FileIncremental",
                    "totalCapacity": 0.0,
                    "licenses": []
                },
                {
                    "capacityType": "File",
                    "capacitySubType": "FileAddOn",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "Log",
            "capacityUnits": "MB",
            "totalCapacity": 0.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "Available",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "Log",
                    "capacitySubType": "LogBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                },
                {
                    "capacityType": "Log",
                    "capacitySubType": "LogAddOn",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "TrialDatabase",
            "capacityUnits": "MB",
            "totalCapacity": 1024000.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "None",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "TrialDatabase",
                    "capacitySubType": "TrialDatabaseBase",
                    "totalCapacity": 1024000.0,
                    "licenses": [
                        {
                            "entitlementCode": "D365_cds_Viral",
                            "displayName": "",
                            "servicePlanId": "17ab22cd-a0b3-4536-910a-00000000000000",
                            "skuId": "f30db892-07e9-47e9-837c-00000000000000",
                            "paid": {
                                "enabled": 10000,
                                "warning": 0,
                                "suspended": 0
                            },
                            "trial": {
                                "enabled": 0,
                                "warning": 0,
                                "suspended": 0
                            },
                            "totalCapacity": 1024000.0,
                            "capabilityStatus": "Enabled"
                        }
                    ]
                }
            ]
        },
        {
            "capacityType": "TrialFile",
            "capacityUnits": "MB",
            "totalCapacity": 0.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "Available",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "TrialFile",
                    "capacitySubType": "TrialFileBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "TrialLog",
            "capacityUnits": "MB",
            "totalCapacity": 0.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "Available",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "TrialLog",
                    "capacitySubType": "TrialLogBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "SubscriptionTrialDatabase",
            "capacityUnits": "MB",
            "totalCapacity": 0.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "None",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "SubscriptionTrialDatabase",
                    "capacitySubType": "SubscriptionTrialDatabaseBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "SubscriptionTrialFile",
            "capacityUnits": "MB",
            "totalCapacity": 0.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "Available",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "SubscriptionTrialFile",
                    "capacitySubType": "SubscriptionTrialFileBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "SubscriptionTrialLog",
            "capacityUnits": "MB",
            "totalCapacity": 0.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "Available",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "SubscriptionTrialDatabase",
                    "capacitySubType": "SubscriptionTrialLogBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "SubscriptionTrialEnvironmentCount",
            "capacityUnits": "Unit",
            "totalCapacity": 0.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "None",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "SubscriptionTrialEnvironmentCount",
                    "capacitySubType": "SubscriptionTrialEnvironmentCountBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                },
                {
                    "capacityType": "SubscriptionTrialEnvironmentCount",
                    "capacitySubType": "SubscriptionTrialEnvironmentCountIncremental",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "M365Database",
            "capacityUnits": "MB",
            "totalCapacity": 10240.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "None",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "M365Database",
                    "capacitySubType": "M365DatabaseBase",
                    "totalCapacity": 10240.0,
                    "maxNextLifecycleDate": "2025-08-16T00:00:00+00:00",
                    "licenses": [
                        {
                            "entitlementCode": "CDS_O365_P3",
                            "displayName": "Common Data Service Lite_P3",
                            "servicePlanId": "afa73018-811e-46e9-988f-00000000000000",
                            "skuId": "18a4bd3f-0b5b-4887-b04f-00000000000000",
                            "paid": {
                                "enabled": 0,
                                "warning": 0,
                                "suspended": 0
                            },
                            "trial": {
                                "enabled": 5,
                                "warning": 0,
                                "suspended": 0
                            },
                            "totalCapacity": 10240.0,
                            "nextLifecycleDate": "2025-08-16T00:00:00+00:00",
                            "capabilityStatus": "Enabled"
                        }
                    ]
                },
                {
                    "capacityType": "M365Database",
                    "capacitySubType": "M365DatabaseIncremental",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "M365EnvironmentCount",
            "capacityUnits": "Unit",
            "totalCapacity": 5.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "None",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "M365EnvironmentCount",
                    "capacitySubType": "M365EnvironmentCountBase",
                    "totalCapacity": 5.0,
                    "maxNextLifecycleDate": "2025-08-16T00:00:00+00:00",
                    "licenses": [
                        {
                            "entitlementCode": "CDS_O365_P3",
                            "displayName": "Common Data Service Lite_P3",
                            "servicePlanId": "afa73018-811e-46e9-988f-00000000000000",
                            "skuId": "18a4bd3f-0b5b-4887-b04f-00000000000000",
                            "paid": {
                                "enabled": 0,
                                "warning": 0,
                                "suspended": 0
                            },
                            "trial": {
                                "enabled": 5,
                                "warning": 0,
                                "suspended": 0
                            },
                            "totalCapacity": 5.0,
                            "nextLifecycleDate": "2025-08-16T00:00:00+00:00",
                            "capabilityStatus": "Enabled"
                        }
                    ]
                },
                {
                    "capacityType": "M365EnvironmentCount",
                    "capacitySubType": "M365EnvironmentCountIncremental",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "CapacityPass",
            "capacityUnits": "Unit",
            "totalCapacity": 0.0,
            "maxCapacity": 1.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "0001-01-01T00:00:00+00:00",
                "ratedUpdatedOn": "0001-01-01T00:00:00+00:00"
            },
            "status": "None",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "CapacityPass",
                    "capacitySubType": "CapacityPassBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "ApiCallCount",
            "capacityUnits": "None",
            "totalCapacity": 25000.0,
            "maxCapacity": 10000000.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "0001-01-01T00:00:00+00:00",
                "ratedUpdatedOn": "0001-01-01T00:00:00+00:00"
            },
            "status": "Available",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "ApiCallCount",
                    "capacitySubType": "ApiCallCountBase",
                    "totalCapacity": 25000.0,
                    "licenses": [
                        {
                            "entitlementCode": "D365_cds_Dev_Viral",
                            "displayName": "",
                            "servicePlanId": "d8c638e2-9508-40e3-9877-00000000000000",
                            "skuId": "5b631642-bd26-49fe-bd20-00000000000000",
                            "paid": {
                                "enabled": 10000,
                                "warning": 0,
                                "suspended": 0
                            },
                            "trial": {
                                "enabled": 0,
                                "warning": 0,
                                "suspended": 0
                            },
                            "totalCapacity": 25000.0,
                            "capabilityStatus": "Enabled"
                        },
                        {
                            "entitlementCode": "D365_cds_Viral",
                            "displayName": "",
                            "servicePlanId": "17ab22cd-a0b3-4536-910a-00000000000000",
                            "skuId": "f30db892-07e9-47e9-837c-00000000000000",
                            "paid": {
                                "enabled": 10000,
                                "warning": 0,
                                "suspended": 0
                            },
                            "trial": {
                                "enabled": 0,
                                "warning": 0,
                                "suspended": 0
                            },
                            "totalCapacity": 25000.0,
                            "capabilityStatus": "Enabled"
                        }
                    ]
                },
                {
                    "capacityType": "ApiCallCount",
                    "capacitySubType": "ApiCallCountIncremental",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "FinOpsDatabase",
            "capacityUnits": "MB",
            "totalCapacity": 0.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "Available",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "FinOpsDatabase",
                    "capacitySubType": "FinOpsDatabaseBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                },
                {
                    "capacityType": "FinOpsDatabase",
                    "capacitySubType": "FinOpsDatabaseIncremental",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        },
        {
            "capacityType": "FinOpsFile",
            "capacityUnits": "MB",
            "totalCapacity": 0.0,
            "maxCapacity": 0.0,
            "consumption": {
                "actual": 0.0,
                "rated": 0.0,
                "actualUpdatedOn": "2024-08-27T16:12:57.4467038+00:00",
                "ratedUpdatedOn": "2024-08-27T16:12:57.4467038+00:00"
            },
            "status": "Available",
            "overflowCapacity": [],
            "capacityEntitlements": [
                {
                    "capacityType": "FinOpsFile",
                    "capacitySubType": "FinOpsFileBase",
                    "totalCapacity": 0.0,
                    "licenses": []
                },
                {
                    "capacityType": "FinOpsFile",
                    "capacitySubType": "FinOpsFileIncremental",
                    "totalCapacity": 0.0,
                    "licenses": []
                }
            ]
        }
    ]
}

Definition of Done

Contributions

Do you plan to raise a PR to address this issue? NO

See the contributing guide for more information about what's expected for contributions.