获取策略元数据资源的列表。
GET https://management.azure.com/providers/Microsoft.PolicyInsights/policyMetadata?api-version=2019-10-01
With optional parameters:
GET https://management.azure.com/providers/Microsoft.PolicyInsights/policyMetadata?api-version=2019-10-01&$top={$top}
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
api-version
|
query |
True
|
string
|
客户端 API 版本。
|
$top
|
query |
|
integer
int32
|
要返回的最大记录数。
|
响应
安全性
azure_auth
Azure Active Directory OAuth2 流
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
Sample Request
GET https://management.azure.com/providers/Microsoft.PolicyInsights/policyMetadata?api-version=2019-10-01
import com.azure.core.util.Context;
/** Samples for PolicyMetadata List. */
public final class Main {
/*
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List.json
*/
/**
* Sample code: Get collection of policy metadata resources.
*
* @param manager Entry point to PolicyInsightsManager.
*/
public static void getCollectionOfPolicyMetadataResources(
com.azure.resourcemanager.policyinsights.PolicyInsightsManager manager) {
manager.policyMetadatas().list(null, Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.policyinsights import PolicyInsightsClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-policyinsights
# USAGE
python policy_metadata_list.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PolicyInsightsClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.policy_metadata.list()
for item in response:
print(item)
# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpolicyinsights_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List.json
func ExamplePolicyMetadataClient_NewListPager_getCollectionOfPolicyMetadataResources() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewPolicyMetadataClient().NewListPager(&armpolicyinsights.QueryOptions{Top: nil,
Filter: nil,
OrderBy: nil,
Select: nil,
From: nil,
To: nil,
Apply: nil,
SkipToken: nil,
Expand: nil,
}, nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.PolicyMetadataCollection = armpolicyinsights.PolicyMetadataCollection{
// Value: []*armpolicyinsights.SlimPolicyMetadata{
// {
// Name: to.Ptr("NIST_SP_800-53_R4_AC-2"),
// Type: to.Ptr("Microsoft.PolicyInsights/policyMetadata"),
// ID: to.Ptr("/providers/Microsoft.PolicyInsights/policyMetadata/NIST_SP_800-53_R4_AC-2"),
// Properties: &armpolicyinsights.PolicyMetadataSlimProperties{
// AdditionalContentURL: to.Ptr("https://aka.ms/NIST_SP_800-53_R4_AC-2"),
// Category: to.Ptr("Access control"),
// Metadata: map[string]any{
// },
// MetadataID: to.Ptr("NIST SP 800-53 R4 AC-2"),
// Owner: to.Ptr("Shared"),
// Title: to.Ptr("Account Management"),
// },
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PolicyInsightsClient } = require("@azure/arm-policyinsights");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Get a list of the policy metadata resources.
*
* @summary Get a list of the policy metadata resources.
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List.json
*/
async function getCollectionOfPolicyMetadataResources() {
const subscriptionId =
process.env["POLICYINSIGHTS_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const credential = new DefaultAzureCredential();
const client = new PolicyInsightsClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.policyMetadataOperations.list()) {
resArray.push(item);
}
console.log(resArray);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.PolicyInsights;
using Azure.ResourceManager.PolicyInsights.Models;
// Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List.json
// this example is just showing the usage of "PolicyMetadata_List" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this TenantResource created on azure
// for more information of creating TenantResource, please refer to the document of TenantResource
var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current;
// get the collection of this PolicyMetadataResource
PolicyMetadataCollection collection = tenantResource.GetAllPolicyMetadata();
// invoke the operation and iterate over the result
await foreach (SlimPolicyMetadata item in collection.GetAllAsync())
{
Console.WriteLine($"Succeeded: {item}");
}
Console.WriteLine($"Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"value": [
{
"properties": {
"metadataId": "NIST SP 800-53 R4 AC-2",
"category": "Access control",
"title": "Account Management",
"owner": "Shared",
"additionalContentUrl": "https://aka.ms/NIST_SP_800-53_R4_AC-2",
"metadata": {}
},
"id": "/providers/Microsoft.PolicyInsights/policyMetadata/NIST_SP_800-53_R4_AC-2",
"name": "NIST_SP_800-53_R4_AC-2",
"type": "Microsoft.PolicyInsights/policyMetadata"
}
]
}
Sample Request
GET https://management.azure.com/providers/Microsoft.PolicyInsights/policyMetadata?api-version=2019-10-01&$top=1
import com.azure.core.util.Context;
/** Samples for PolicyMetadata List. */
public final class Main {
/*
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List_WithTop.json
*/
/**
* Sample code: Get collection of policy metadata resources using top query parameter.
*
* @param manager Entry point to PolicyInsightsManager.
*/
public static void getCollectionOfPolicyMetadataResourcesUsingTopQueryParameter(
com.azure.resourcemanager.policyinsights.PolicyInsightsManager manager) {
manager.policyMetadatas().list(1, Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.policyinsights import PolicyInsightsClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-policyinsights
# USAGE
python policy_metadata_list_with_top.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PolicyInsightsClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.policy_metadata.list()
for item in response:
print(item)
# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List_WithTop.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpolicyinsights_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List_WithTop.json
func ExamplePolicyMetadataClient_NewListPager_getCollectionOfPolicyMetadataResourcesUsingTopQueryParameter() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewPolicyMetadataClient().NewListPager(&armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1),
Filter: nil,
OrderBy: nil,
Select: nil,
From: nil,
To: nil,
Apply: nil,
SkipToken: nil,
Expand: nil,
}, nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.PolicyMetadataCollection = armpolicyinsights.PolicyMetadataCollection{
// Value: []*armpolicyinsights.SlimPolicyMetadata{
// {
// Name: to.Ptr("NIST_SP_800-53_R4_AC-2"),
// Type: to.Ptr("Microsoft.PolicyInsights/policyMetadata"),
// ID: to.Ptr("/providers/Microsoft.PolicyInsights/policyMetadata/NIST_SP_800-53_R4_AC-2"),
// Properties: &armpolicyinsights.PolicyMetadataSlimProperties{
// AdditionalContentURL: to.Ptr("https://aka.ms/NIST_SP_800-53_R4_AC-2"),
// Category: to.Ptr("Access control"),
// Metadata: map[string]any{
// },
// MetadataID: to.Ptr("NIST SP 800-53 R4 AC-2"),
// Owner: to.Ptr("Shared"),
// Title: to.Ptr("Account Management"),
// },
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PolicyInsightsClient } = require("@azure/arm-policyinsights");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Get a list of the policy metadata resources.
*
* @summary Get a list of the policy metadata resources.
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List_WithTop.json
*/
async function getCollectionOfPolicyMetadataResourcesUsingTopQueryParameter() {
const subscriptionId =
process.env["POLICYINSIGHTS_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const top = 1;
const options = { queryOptions: { top: top } };
const credential = new DefaultAzureCredential();
const client = new PolicyInsightsClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.policyMetadataOperations.list(options)) {
resArray.push(item);
}
console.log(resArray);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.PolicyInsights;
using Azure.ResourceManager.PolicyInsights.Models;
// Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List_WithTop.json
// this example is just showing the usage of "PolicyMetadata_List" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this TenantResource created on azure
// for more information of creating TenantResource, please refer to the document of TenantResource
var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current;
// get the collection of this PolicyMetadataResource
PolicyMetadataCollection collection = tenantResource.GetAllPolicyMetadata();
// invoke the operation and iterate over the result
await foreach (SlimPolicyMetadata item in collection.GetAllAsync())
{
Console.WriteLine($"Succeeded: {item}");
}
Console.WriteLine($"Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"value": [
{
"properties": {
"metadataId": "NIST SP 800-53 R4 AC-2",
"category": "Access control",
"title": "Account Management",
"owner": "Shared",
"additionalContentUrl": "https://aka.ms/NIST_SP_800-53_R4_AC-2",
"metadata": {}
},
"id": "/providers/Microsoft.PolicyInsights/policyMetadata/NIST_SP_800-53_R4_AC-2",
"name": "NIST_SP_800-53_R4_AC-2",
"type": "Microsoft.PolicyInsights/policyMetadata"
}
]
}
定义
ErrorDefinition
错误定义。
名称 |
类型 |
说明 |
additionalInfo
|
TypedErrorInfo[]
|
其他特定于方案的错误详细信息。
|
code
|
string
|
服务特定的错误代码,用作 HTTP 错误代码的子状态。
|
details
|
ErrorDefinition[]
|
内部错误详细信息。
|
message
|
string
|
错误的说明。
|
target
|
string
|
错误的目标。
|
ErrorResponse
错误响应。
策略元数据资源的集合。
精简版本的策略元数据资源定义,不包括具有大字符串的属性
名称 |
类型 |
说明 |
id
|
string
|
策略元数据的 ID。
|
name
|
string
|
策略元数据的名称。
|
properties.additionalContentUrl
|
string
|
用于获取有关资源元数据的其他内容的 URL。
|
properties.category
|
string
|
策略元数据的类别。
|
properties.metadata
|
object
|
其他元数据。
|
properties.metadataId
|
string
|
策略元数据标识符。
|
properties.owner
|
string
|
策略元数据的所有者。
|
properties.title
|
string
|
策略元数据的标题。
|
type
|
string
|
策略元数据的类型。
|
TypedErrorInfo
特定于方案的错误详细信息。
名称 |
类型 |
说明 |
info
|
|
特定于方案的错误详细信息。
|
type
|
string
|
包含的错误详细信息的类型。
|