diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/api/Azure.ResourceManager.SecurityCenter.netstandard2.0.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/api/Azure.ResourceManager.SecurityCenter.netstandard2.0.cs index 72cf9a5f0f62..bf878c649193 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/api/Azure.ResourceManager.SecurityCenter.netstandard2.0.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/api/Azure.ResourceManager.SecurityCenter.netstandard2.0.cs @@ -86,6 +86,41 @@ protected AdvancedThreatProtectionSettingResource() { } public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } + public partial class ApiCollectionResponseCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected ApiCollectionResponseCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string apiCollectionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string apiCollectionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string apiCollectionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string apiCollectionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string apiCollectionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string apiCollectionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class ApiCollectionResponseData : Azure.ResourceManager.Models.ResourceData + { + public ApiCollectionResponseData() { } + public System.Collections.Generic.IDictionary AdditionalData { get { throw null; } } + public string DisplayName { get { throw null; } set { } } + } + public partial class ApiCollectionResponseResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected ApiCollectionResponseResource() { } + public virtual Azure.ResourceManager.SecurityCenter.ApiCollectionResponseData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string serviceName, string apiCollectionId) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } public partial class AutoProvisioningSettingCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected AutoProvisioningSettingCollection() { } @@ -952,6 +987,10 @@ public static partial class SecurityCenterExtensions public static Azure.AsyncPageable GetAllSecuritySolutionsReferenceDataAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.ResourceManager.SecurityCenter.SubscriptionAssessmentMetadataCollection GetAllSubscriptionAssessmentMetadata(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource) { throw null; } public static Azure.ResourceManager.SecurityCenter.TenantAssessmentMetadataCollection GetAllTenantAssessmentMetadata(this Azure.ResourceManager.Resources.TenantResource tenantResource) { throw null; } + public static Azure.Response GetApiCollectionResponse(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string serviceName, string apiCollectionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetApiCollectionResponseAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string serviceName, string apiCollectionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.SecurityCenter.ApiCollectionResponseResource GetApiCollectionResponseResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.SecurityCenter.ApiCollectionResponseCollection GetApiCollectionResponses(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string serviceName) { throw null; } public static Azure.Response GetAutoProvisioningSetting(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string settingName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static System.Threading.Tasks.Task> GetAutoProvisioningSettingAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string settingName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.ResourceManager.SecurityCenter.AutoProvisioningSettingResource GetAutoProvisioningSettingResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/ApiCollectionResponseCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/ApiCollectionResponseCollection.cs new file mode 100644 index 000000000000..5f2bb1564842 --- /dev/null +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/ApiCollectionResponseCollection.cs @@ -0,0 +1,340 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.SecurityCenter +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get an instance call the GetApiCollectionResponses method from an instance of . + /// + public partial class ApiCollectionResponseCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _apiCollectionResponseAPICollectionOnboardingClientDiagnostics; + private readonly APICollectionOnboardingRestOperations _apiCollectionResponseAPICollectionOnboardingRestClient; + private readonly ClientDiagnostics _apiCollectionResponseAPICollectionClientDiagnostics; + private readonly APICollectionRestOperations _apiCollectionResponseAPICollectionRestClient; + private readonly string _serviceName; + + /// Initializes a new instance of the class for mocking. + protected ApiCollectionResponseCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + /// The name of the API Management service. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal ApiCollectionResponseCollection(ArmClient client, ResourceIdentifier id, string serviceName) : base(client, id) + { + _serviceName = serviceName; + _apiCollectionResponseAPICollectionOnboardingClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SecurityCenter", ApiCollectionResponseResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ApiCollectionResponseResource.ResourceType, out string apiCollectionResponseAPICollectionOnboardingApiVersion); + _apiCollectionResponseAPICollectionOnboardingRestClient = new APICollectionOnboardingRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, apiCollectionResponseAPICollectionOnboardingApiVersion); + _apiCollectionResponseAPICollectionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SecurityCenter", ApiCollectionResponseResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ApiCollectionResponseResource.ResourceType, out string apiCollectionResponseAPICollectionApiVersion); + _apiCollectionResponseAPICollectionRestClient = new APICollectionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, apiCollectionResponseAPICollectionApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + } + + /// + /// Onboard an Azure API Management API to Defender for APIs. The system will start monitoring the operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollectionOnboarding_Create + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var scope = _apiCollectionResponseAPICollectionOnboardingClientDiagnostics.CreateScope("ApiCollectionResponseCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _apiCollectionResponseAPICollectionOnboardingRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, _serviceName, apiCollectionId, cancellationToken).ConfigureAwait(false); + var operation = new SecurityCenterArmOperation(Response.FromValue(new ApiCollectionResponseResource(Client, response), response.GetRawResponse())); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Onboard an Azure API Management API to Defender for APIs. The system will start monitoring the operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollectionOnboarding_Create + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var scope = _apiCollectionResponseAPICollectionOnboardingClientDiagnostics.CreateScope("ApiCollectionResponseCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _apiCollectionResponseAPICollectionOnboardingRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, _serviceName, apiCollectionId, cancellationToken); + var operation = new SecurityCenterArmOperation(Response.FromValue(new ApiCollectionResponseResource(Client, response), response.GetRawResponse())); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets an Azure API Management API if it has been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollection_Get + /// + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var scope = _apiCollectionResponseAPICollectionClientDiagnostics.CreateScope("ApiCollectionResponseCollection.Get"); + scope.Start(); + try + { + var response = await _apiCollectionResponseAPICollectionRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, _serviceName, apiCollectionId, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ApiCollectionResponseResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets an Azure API Management API if it has been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollection_Get + /// + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var scope = _apiCollectionResponseAPICollectionClientDiagnostics.CreateScope("ApiCollectionResponseCollection.Get"); + scope.Start(); + try + { + var response = _apiCollectionResponseAPICollectionRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, _serviceName, apiCollectionId, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ApiCollectionResponseResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets a list of Azure API Management APIs that have been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections + /// Operation Id: APICollection_List + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _apiCollectionResponseAPICollectionClientDiagnostics.CreateScope("ApiCollectionResponseCollection.GetAll"); + scope.Start(); + try + { + var response = await _apiCollectionResponseAPICollectionRestClient.ListAsync(Id.SubscriptionId, Id.ResourceGroupName, _serviceName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value.Select(value => new ApiCollectionResponseResource(Client, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _apiCollectionResponseAPICollectionClientDiagnostics.CreateScope("ApiCollectionResponseCollection.GetAll"); + scope.Start(); + try + { + var response = await _apiCollectionResponseAPICollectionRestClient.ListNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, _serviceName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value.Select(value => new ApiCollectionResponseResource(Client, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// + /// Gets a list of Azure API Management APIs that have been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections + /// Operation Id: APICollection_List + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _apiCollectionResponseAPICollectionClientDiagnostics.CreateScope("ApiCollectionResponseCollection.GetAll"); + scope.Start(); + try + { + var response = _apiCollectionResponseAPICollectionRestClient.List(Id.SubscriptionId, Id.ResourceGroupName, _serviceName, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value.Select(value => new ApiCollectionResponseResource(Client, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _apiCollectionResponseAPICollectionClientDiagnostics.CreateScope("ApiCollectionResponseCollection.GetAll"); + scope.Start(); + try + { + var response = _apiCollectionResponseAPICollectionRestClient.ListNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, _serviceName, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value.Select(value => new ApiCollectionResponseResource(Client, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// + /// Checks to see if the resource exists in azure. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollection_Get + /// + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var scope = _apiCollectionResponseAPICollectionClientDiagnostics.CreateScope("ApiCollectionResponseCollection.Exists"); + scope.Start(); + try + { + var response = await _apiCollectionResponseAPICollectionRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, _serviceName, apiCollectionId, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollection_Get + /// + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var scope = _apiCollectionResponseAPICollectionClientDiagnostics.CreateScope("ApiCollectionResponseCollection.Exists"); + scope.Start(); + try + { + var response = _apiCollectionResponseAPICollectionRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, _serviceName, apiCollectionId, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/ApiCollectionResponseData.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/ApiCollectionResponseData.cs new file mode 100644 index 000000000000..c4c4dea2b7e3 --- /dev/null +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/ApiCollectionResponseData.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.SecurityCenter +{ + /// A class representing the ApiCollectionResponse data model. + public partial class ApiCollectionResponseData : ResourceData + { + /// Initializes a new instance of ApiCollectionResponseData. + public ApiCollectionResponseData() + { + AdditionalData = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of ApiCollectionResponseData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The display name of the Azure API Management API. + /// Additional data regarding the API collection. + internal ApiCollectionResponseData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string displayName, IDictionary additionalData) : base(id, name, resourceType, systemData) + { + DisplayName = displayName; + AdditionalData = additionalData; + } + + /// The display name of the Azure API Management API. + public string DisplayName { get; set; } + /// Additional data regarding the API collection. + public IDictionary AdditionalData { get; } + } +} diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/ApiCollectionResponseResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/ApiCollectionResponseResource.cs new file mode 100644 index 000000000000..955379a83558 --- /dev/null +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/ApiCollectionResponseResource.cs @@ -0,0 +1,252 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.SecurityCenter +{ + /// + /// A Class representing an ApiCollectionResponse along with the instance operations that can be performed on it. + /// If you have a you can construct an + /// from an instance of using the GetApiCollectionResponseResource method. + /// Otherwise you can get one from its parent resource using the GetApiCollectionResponse method. + /// + public partial class ApiCollectionResponseResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string serviceName, string apiCollectionId) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _apiCollectionResponseAPICollectionClientDiagnostics; + private readonly APICollectionRestOperations _apiCollectionResponseAPICollectionRestClient; + private readonly ClientDiagnostics _apiCollectionResponseAPICollectionOffboardingClientDiagnostics; + private readonly APICollectionOffboardingRestOperations _apiCollectionResponseAPICollectionOffboardingRestClient; + private readonly ClientDiagnostics _apiCollectionResponseAPICollectionOnboardingClientDiagnostics; + private readonly APICollectionOnboardingRestOperations _apiCollectionResponseAPICollectionOnboardingRestClient; + private readonly ApiCollectionResponseData _data; + + /// Initializes a new instance of the class for mocking. + protected ApiCollectionResponseResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ApiCollectionResponseResource(ArmClient client, ApiCollectionResponseData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ApiCollectionResponseResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _apiCollectionResponseAPICollectionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SecurityCenter", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string apiCollectionResponseAPICollectionApiVersion); + _apiCollectionResponseAPICollectionRestClient = new APICollectionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, apiCollectionResponseAPICollectionApiVersion); + _apiCollectionResponseAPICollectionOffboardingClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SecurityCenter", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string apiCollectionResponseAPICollectionOffboardingApiVersion); + _apiCollectionResponseAPICollectionOffboardingRestClient = new APICollectionOffboardingRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, apiCollectionResponseAPICollectionOffboardingApiVersion); + _apiCollectionResponseAPICollectionOnboardingClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SecurityCenter", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string apiCollectionResponseAPICollectionOnboardingApiVersion); + _apiCollectionResponseAPICollectionOnboardingRestClient = new APICollectionOnboardingRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, apiCollectionResponseAPICollectionOnboardingApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Security/apiCollections"; + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual ApiCollectionResponseData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Gets an Azure API Management API if it has been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollection_Get + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _apiCollectionResponseAPICollectionClientDiagnostics.CreateScope("ApiCollectionResponseResource.Get"); + scope.Start(); + try + { + var response = await _apiCollectionResponseAPICollectionRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ApiCollectionResponseResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets an Azure API Management API if it has been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollection_Get + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _apiCollectionResponseAPICollectionClientDiagnostics.CreateScope("ApiCollectionResponseResource.Get"); + scope.Start(); + try + { + var response = _apiCollectionResponseAPICollectionRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ApiCollectionResponseResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Offboard an Azure API Management API from Defender for APIs. The system will stop monitoring the operations within the Azure API Management API for intrusive behaviors. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollectionOffboarding_Delete + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _apiCollectionResponseAPICollectionOffboardingClientDiagnostics.CreateScope("ApiCollectionResponseResource.Delete"); + scope.Start(); + try + { + var response = await _apiCollectionResponseAPICollectionOffboardingRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new SecurityCenterArmOperation(response); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Offboard an Azure API Management API from Defender for APIs. The system will stop monitoring the operations within the Azure API Management API for intrusive behaviors. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollectionOffboarding_Delete + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _apiCollectionResponseAPICollectionOffboardingClientDiagnostics.CreateScope("ApiCollectionResponseResource.Delete"); + scope.Start(); + try + { + var response = _apiCollectionResponseAPICollectionOffboardingRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new SecurityCenterArmOperation(response); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Onboard an Azure API Management API to Defender for APIs. The system will start monitoring the operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollectionOnboarding_Create + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _apiCollectionResponseAPICollectionOnboardingClientDiagnostics.CreateScope("ApiCollectionResponseResource.Update"); + scope.Start(); + try + { + var response = await _apiCollectionResponseAPICollectionOnboardingRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new SecurityCenterArmOperation(Response.FromValue(new ApiCollectionResponseResource(Client, response), response.GetRawResponse())); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Onboard an Azure API Management API to Defender for APIs. The system will start monitoring the operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollectionOnboarding_Create + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Update(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _apiCollectionResponseAPICollectionOnboardingClientDiagnostics.CreateScope("ApiCollectionResponseResource.Update"); + scope.Start(); + try + { + var response = _apiCollectionResponseAPICollectionOnboardingRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new SecurityCenterArmOperation(Response.FromValue(new ApiCollectionResponseResource(Client, response), response.GetRawResponse())); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs index 47cfa098bdf5..1fb1875d9989 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs @@ -157,6 +157,14 @@ public virtual SecurityConnectorCollection GetSecurityConnectors() return GetCachedClient(Client => new SecurityConnectorCollection(Client, Id)); } + /// Gets a collection of ApiCollectionResponseResources in the ResourceGroupResource. + /// The name of the API Management service. + /// An object representing collection of ApiCollectionResponseResources and their operations over a ApiCollectionResponseResource. + public virtual ApiCollectionResponseCollection GetApiCollectionResponses(string serviceName) + { + return new ApiCollectionResponseCollection(Client, Id, serviceName); + } + /// /// Gets the list of all possible traffic between resources for the subscription and location, based on connection type. /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType} diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Extensions/SecurityCenterExtensions.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Extensions/SecurityCenterExtensions.cs index 2467f452d54a..ae4339733795 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Extensions/SecurityCenterExtensions.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Extensions/SecurityCenterExtensions.cs @@ -1684,6 +1684,53 @@ public static Response GetSecurityConnector(this Reso return resourceGroupResource.GetSecurityConnectors().Get(securityConnectorName, cancellationToken); } + /// Gets a collection of ApiCollectionResponseResources in the ResourceGroupResource. + /// The instance the method will execute against. + /// The name of the API Management service. + /// is an empty string, and was expected to be non-empty. + /// is null. + /// An object representing collection of ApiCollectionResponseResources and their operations over a ApiCollectionResponseResource. + public static ApiCollectionResponseCollection GetApiCollectionResponses(this ResourceGroupResource resourceGroupResource, string serviceName) + { + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + return GetExtensionClient(resourceGroupResource).GetApiCollectionResponses(serviceName); + } + + /// + /// Gets an Azure API Management API if it has been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollection_Get + /// + /// The instance the method will execute against. + /// The name of the API Management service. + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// or is null. + [ForwardsClientCalls] + public static async Task> GetApiCollectionResponseAsync(this ResourceGroupResource resourceGroupResource, string serviceName, string apiCollectionId, CancellationToken cancellationToken = default) + { + return await resourceGroupResource.GetApiCollectionResponses(serviceName).GetAsync(apiCollectionId, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an Azure API Management API if it has been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId} + /// Operation Id: APICollection_Get + /// + /// The instance the method will execute against. + /// The name of the API Management service. + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// or is null. + [ForwardsClientCalls] + public static Response GetApiCollectionResponse(this ResourceGroupResource resourceGroupResource, string serviceName, string apiCollectionId, CancellationToken cancellationToken = default) + { + return resourceGroupResource.GetApiCollectionResponses(serviceName).Get(apiCollectionId, cancellationToken); + } + /// /// Gets the list of all possible traffic between resources for the subscription and location, based on connection type. /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType} @@ -3053,5 +3100,24 @@ public static SecurityConnectorApplicationResource GetSecurityConnectorApplicati ); } #endregion + + #region ApiCollectionResponseResource + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static ApiCollectionResponseResource GetApiCollectionResponseResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + ApiCollectionResponseResource.ValidateResourceId(id); + return new ApiCollectionResponseResource(client, id); + } + ); + } + #endregion } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Models/ApiCollectionResponseData.Serialization.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Models/ApiCollectionResponseData.Serialization.cs new file mode 100644 index 000000000000..4d267f233720 --- /dev/null +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Models/ApiCollectionResponseData.Serialization.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.SecurityCenter +{ + public partial class ApiCollectionResponseData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsCollectionDefined(AdditionalData)) + { + writer.WritePropertyName("additionalData"); + writer.WriteStartObject(); + foreach (var item in AdditionalData) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static ApiCollectionResponseData DeserializeApiCollectionResponseData(JsonElement element) + { + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional displayName = default; + Optional> additionalData = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.ToString()); + continue; + } + if (property.NameEquals("properties")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("displayName")) + { + displayName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("additionalData")) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property1 in property0.Value.EnumerateObject()) + { + dictionary.Add(property1.Name, property1.Value.GetString()); + } + additionalData = dictionary; + continue; + } + } + continue; + } + } + return new ApiCollectionResponseData(id, name, type, systemData.Value, displayName.Value, Optional.ToDictionary(additionalData)); + } + } +} diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Models/ApiCollectionResponseList.Serialization.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Models/ApiCollectionResponseList.Serialization.cs new file mode 100644 index 000000000000..390addf5cb7f --- /dev/null +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Models/ApiCollectionResponseList.Serialization.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.SecurityCenter; + +namespace Azure.ResourceManager.SecurityCenter.Models +{ + internal partial class ApiCollectionResponseList + { + internal static ApiCollectionResponseList DeserializeApiCollectionResponseList(JsonElement element) + { + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ApiCollectionResponseData.DeserializeApiCollectionResponseData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new ApiCollectionResponseList(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Models/ApiCollectionResponseList.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Models/ApiCollectionResponseList.cs new file mode 100644 index 000000000000..5f50e2d0e7c0 --- /dev/null +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/Models/ApiCollectionResponseList.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.SecurityCenter; + +namespace Azure.ResourceManager.SecurityCenter.Models +{ + /// Page of a list of API collections as represented by Defender for APIs. + internal partial class ApiCollectionResponseList + { + /// Initializes a new instance of ApiCollectionResponseList. + internal ApiCollectionResponseList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of ApiCollectionResponseList. + /// API collections in this page. + /// The URI to fetch the next page. + internal ApiCollectionResponseList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// API collections in this page. + public IReadOnlyList Value { get; } + /// The URI to fetch the next page. + public string NextLink { get; } + } +} diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/RestOperations/APICollectionOffboardingRestOperations.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/RestOperations/APICollectionOffboardingRestOperations.cs new file mode 100644 index 000000000000..4fd1c6b32821 --- /dev/null +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/RestOperations/APICollectionOffboardingRestOperations.cs @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.SecurityCenter +{ + internal partial class APICollectionOffboardingRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of APICollectionOffboardingRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public APICollectionOffboardingRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2022-11-20-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string serviceName, string apiCollectionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ApiManagement/service/", false); + uri.AppendPath(serviceName, true); + uri.AppendPath("/providers/Microsoft.Security/apiCollections/", false); + uri.AppendPath(apiCollectionId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Offboard an Azure API Management API from Defender for APIs. The system will stop monitoring the operations within the Azure API Management API for intrusive behaviors. + /// Azure subscription ID. + /// The name of the resource group. The name is case insensitive. + /// The name of the API Management service. + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string serviceName, string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, serviceName, apiCollectionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Offboard an Azure API Management API from Defender for APIs. The system will stop monitoring the operations within the Azure API Management API for intrusive behaviors. + /// Azure subscription ID. + /// The name of the resource group. The name is case insensitive. + /// The name of the API Management service. + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string serviceName, string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, serviceName, apiCollectionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/RestOperations/APICollectionOnboardingRestOperations.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/RestOperations/APICollectionOnboardingRestOperations.cs new file mode 100644 index 000000000000..77161631e381 --- /dev/null +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/RestOperations/APICollectionOnboardingRestOperations.cs @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.SecurityCenter +{ + internal partial class APICollectionOnboardingRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of APICollectionOnboardingRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public APICollectionOnboardingRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2022-11-20-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string serviceName, string apiCollectionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ApiManagement/service/", false); + uri.AppendPath(serviceName, true); + uri.AppendPath("/providers/Microsoft.Security/apiCollections/", false); + uri.AppendPath(apiCollectionId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Onboard an Azure API Management API to Defender for APIs. The system will start monitoring the operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Azure subscription ID. + /// The name of the resource group. The name is case insensitive. + /// The name of the API Management service. + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> CreateAsync(string subscriptionId, string resourceGroupName, string serviceName, string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, serviceName, apiCollectionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ApiCollectionResponseData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ApiCollectionResponseData.DeserializeApiCollectionResponseData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Onboard an Azure API Management API to Defender for APIs. The system will start monitoring the operations within the Azure Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Azure subscription ID. + /// The name of the resource group. The name is case insensitive. + /// The name of the API Management service. + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Create(string subscriptionId, string resourceGroupName, string serviceName, string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, serviceName, apiCollectionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ApiCollectionResponseData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ApiCollectionResponseData.DeserializeApiCollectionResponseData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/RestOperations/APICollectionRestOperations.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/RestOperations/APICollectionRestOperations.cs new file mode 100644 index 000000000000..a9da10f3a1ee --- /dev/null +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/Generated/RestOperations/APICollectionRestOperations.cs @@ -0,0 +1,283 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.SecurityCenter.Models; + +namespace Azure.ResourceManager.SecurityCenter +{ + internal partial class APICollectionRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of APICollectionRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public APICollectionRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2022-11-20-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string serviceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ApiManagement/service/", false); + uri.AppendPath(serviceName, true); + uri.AppendPath("/providers/Microsoft.Security/apiCollections", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets a list of Azure API Management APIs that have been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Azure subscription ID. + /// The name of the resource group. The name is case insensitive. + /// The name of the API Management service. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, serviceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ApiCollectionResponseList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ApiCollectionResponseList.DeserializeApiCollectionResponseList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets a list of Azure API Management APIs that have been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Azure subscription ID. + /// The name of the resource group. The name is case insensitive. + /// The name of the API Management service. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, serviceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ApiCollectionResponseList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ApiCollectionResponseList.DeserializeApiCollectionResponseList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string serviceName, string apiCollectionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ApiManagement/service/", false); + uri.AppendPath(serviceName, true); + uri.AppendPath("/providers/Microsoft.Security/apiCollections/", false); + uri.AppendPath(apiCollectionId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets an Azure API Management API if it has been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Azure subscription ID. + /// The name of the resource group. The name is case insensitive. + /// The name of the API Management service. + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string serviceName, string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, serviceName, apiCollectionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ApiCollectionResponseData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ApiCollectionResponseData.DeserializeApiCollectionResponseData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ApiCollectionResponseData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets an Azure API Management API if it has been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// Azure subscription ID. + /// The name of the resource group. The name is case insensitive. + /// The name of the API Management service. + /// A string representing the apiCollections resource within the Microsoft.Security provider namespace. This string matches the Azure API Management API name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string serviceName, string apiCollectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + Argument.AssertNotNullOrEmpty(apiCollectionId, nameof(apiCollectionId)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, serviceName, apiCollectionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ApiCollectionResponseData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ApiCollectionResponseData.DeserializeApiCollectionResponseData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ApiCollectionResponseData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string serviceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets a list of Azure API Management APIs that have been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// The URL to the next page of results. + /// Azure subscription ID. + /// The name of the resource group. The name is case insensitive. + /// The name of the API Management service. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, serviceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ApiCollectionResponseList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ApiCollectionResponseList.DeserializeApiCollectionResponseList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets a list of Azure API Management APIs that have been onboarded to Defender for APIs. If an Azure API Management API is onboarded to Defender for APIs, the system will monitor the operations within the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. + /// The URL to the next page of results. + /// Azure subscription ID. + /// The name of the resource group. The name is case insensitive. + /// The name of the API Management service. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, serviceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ApiCollectionResponseList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ApiCollectionResponseList.DeserializeApiCollectionResponseList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/autorest.md b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/autorest.md index 2f989a930772..2c060a40d651 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/autorest.md +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/src/autorest.md @@ -8,7 +8,7 @@ azure-arm: true csharp: true library-name: SecurityCenter namespace: Azure.ResourceManager.SecurityCenter -require: https://github.com/Azure/azure-rest-api-specs/blob/f7386016ed8edfdc59d00003c1298afa6966842c/specification/security/resource-manager/readme.md +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/security/resource-manager/readme.md output-folder: $(this-folder)/Generated clear-output-folder: true skip-csproj: true