Получение списка ресурсов метаданных политики.
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
Поток OAuth2 в Azure Active Directory
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
Ответ об ошибке.
Коллекция ресурсов метаданных политики.
Имя |
Тип |
Описание |
nextLink
|
string
|
URL-адрес для получения следующего набора результатов.
|
value
|
SlimPolicyMetadata[]
|
Массив определений метаданных политики.
|
Тонкая версия определения ресурса метаданных политики, за исключением свойств с большими строками
Имя |
Тип |
Описание |
id
|
string
|
Идентификатор метаданных политики.
|
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
|
Тип включенных сведений об ошибке.
|