获取已载入到 Microsoft Defender for API 的订阅中的 API 集合列表。
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Security/apiCollections?api-version=2023-11-15
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
subscriptionId
|
path |
True
|
string
uuid
|
目标订阅的 ID。 该值必须是 UUID。
|
api-version
|
query |
True
|
string
|
用于此操作的 API 版本。
|
响应
安全性
azure_auth
Azure Active Directory OAuth2 Flow
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
Gets a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs
示例请求
GET https://management.azure.com/subscriptions/3fa85f64-5717-4562-b3fc-2c963f66afa6/providers/Microsoft.Security/apiCollections?api-version=2023-11-15
/**
* Samples for ApiCollections List.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/
* APICollections_ListBySubscription_example.json
*/
/**
* Sample code: Gets a list of API collections within a subscription that have been onboarded to Microsoft Defender
* for APIs.
*
* @param manager Entry point to SecurityManager.
*/
public static void getsAListOfAPICollectionsWithinASubscriptionThatHaveBeenOnboardedToMicrosoftDefenderForAPIs(
com.azure.resourcemanager.security.SecurityManager manager) {
manager.apiCollections().list(com.azure.core.util.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
package armsecurity_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ac34f238dd6b9071f486b57e9f9f1a0c43ec6f6/specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListBySubscription_example.json
func ExampleAPICollectionsClient_NewListBySubscriptionPager() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armsecurity.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewAPICollectionsClient().NewListBySubscriptionPager(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.APICollectionList = armsecurity.APICollectionList{
// Value: []*armsecurity.APICollection{
// {
// Name: to.Ptr("echo-api"),
// Type: to.Ptr("Microsoft.Security/apiCollections"),
// ID: to.Ptr("/subscriptions/3fa85f64-5717-4562-b3fc-2c963f66afa6/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/providers/Microsoft.Security/apiCollections/echo-api"),
// Properties: &armsecurity.APICollectionProperties{
// BaseURL: to.Ptr("https://apimservice1.azure-api.net/echo"),
// DiscoveredVia: to.Ptr("/subscriptions/3fa85f64-5717-4562-b3fc-2c963f66afa6/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"),
// DisplayName: to.Ptr("Echo API"),
// NumberOfAPIEndpoints: to.Ptr[int64](6),
// NumberOfAPIEndpointsWithSensitiveDataExposed: to.Ptr[int64](1),
// NumberOfExternalAPIEndpoints: to.Ptr[int64](3),
// NumberOfInactiveAPIEndpoints: to.Ptr[int64](3),
// NumberOfUnauthenticatedAPIEndpoints: to.Ptr[int64](1),
// ProvisioningState: to.Ptr(armsecurity.ProvisioningStateSucceeded),
// SensitivityLabel: to.Ptr("Highly Confidential"),
// },
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SecurityCenter } = require("@azure/arm-security");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs.
*
* @summary Gets a list of API collections within a subscription that have been onboarded to Microsoft Defender for APIs.
* x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListBySubscription_example.json
*/
async function getsAListOfApiCollectionsWithinASubscriptionThatHaveBeenOnboardedToMicrosoftDefenderForApIs() {
const subscriptionId =
process.env["SECURITY_SUBSCRIPTION_ID"] || "3fa85f64-5717-4562-b3fc-2c963f66afa6";
const credential = new DefaultAzureCredential();
const client = new SecurityCenter(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.aPICollections.listBySubscription()) {
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.Resources;
using Azure.ResourceManager.SecurityCenter;
// Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListBySubscription_example.json
// this example is just showing the usage of "APICollections_ListBySubscription" 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 SubscriptionResource created on azure
// for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource
string subscriptionId = "3fa85f64-5717-4562-b3fc-2c963f66afa6";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// invoke the operation and iterate over the result
await foreach (SecurityCenterApiCollectionResource item in subscriptionResource.GetSecurityCenterApiCollectionsAsync())
{
// the variable item is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SecurityCenterApiCollectionData resourceData = item.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
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
示例响应
{
"value": [
{
"id": "/subscriptions/3fa85f64-5717-4562-b3fc-2c963f66afa6/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/providers/Microsoft.Security/apiCollections/echo-api",
"name": "echo-api",
"type": "Microsoft.Security/apiCollections",
"properties": {
"provisioningState": "Succeeded",
"displayName": "Echo API",
"discoveredVia": "/subscriptions/3fa85f64-5717-4562-b3fc-2c963f66afa6/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1",
"baseUrl": "https://apimservice1.azure-api.net/echo",
"numberOfApiEndpoints": 6,
"numberOfInactiveApiEndpoints": 3,
"numberOfUnauthenticatedApiEndpoints": 1,
"numberOfExternalApiEndpoints": 3,
"numberOfApiEndpointsWithSensitiveDataExposed": 1,
"sensitivityLabel": "Highly Confidential"
}
}
],
"nextLink": "https://management.azure.com/subscriptions/3fa85f64-5717-4562-b3fc-2c963f66afa6/providers/Microsoft.Security/apiCollections?api-version=2023-11-15&$skipToken=ac943fd6a934"
}
定义
ApiCollection
由 Microsoft Defender for API 表示的 API 集合。
名称 |
类型 |
说明 |
id
|
string
|
资源 ID
|
name
|
string
|
资源名称
|
properties.baseUrl
|
string
|
此 API 集合的基本 URI。 此 API 集合的所有终结点都会扩展此基 URI。
|
properties.discoveredVia
|
string
|
从中发现此 API 集合的资源的资源 ID。
|
properties.displayName
|
string
|
API 集合的显示名称。
|
properties.numberOfApiEndpoints
|
integer
|
在此 API 集合中发现的 API 终结点数。
|
properties.numberOfApiEndpointsWithSensitiveDataExposed
|
integer
|
此 API 集合中公开其请求和/或响应中的敏感数据的 API 终结点数。
|
properties.numberOfExternalApiEndpoints
|
integer
|
此 API 集合中观察到来自 Internet 的 API 流量的 API 终结点数。
|
properties.numberOfInactiveApiEndpoints
|
integer
|
此 API 集合中在过去 30 天内未收到任何 API 流量的 API 终结点数。
|
properties.numberOfUnauthenticatedApiEndpoints
|
integer
|
此 API 集合中未经身份验证的 API 终结点数。
|
properties.provisioningState
|
ProvisioningState
|
获取 API 集合的预配状态。
|
properties.sensitivityLabel
|
string
|
此 API 集合中来自 Microsoft Purview 的最高优先级敏感度标签。
|
type
|
string
|
资源类型
|
ApiCollectionList
MICROSOFT Defender for API 所表示的 API 集合列表的页面。
名称 |
类型 |
说明 |
nextLink
|
string
|
要提取下一页的 URI。
|
value
|
ApiCollection[]
|
此页面中的 API 集合。
|
ErrorAdditionalInfo
资源管理错误附加信息。
名称 |
类型 |
说明 |
info
|
object
|
其他信息。
|
type
|
string
|
其他信息类型。
|
ErrorDetail
错误详细信息。
ErrorResponse
错误响应
ProvisioningState
获取 API 集合的预配状态。
名称 |
类型 |
说明 |
Canceled
|
string
|
|
Failed
|
string
|
|
InProgress
|
string
|
|
Succeeded
|
string
|
|