diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/Azure.ResourceManager.Storageactions.sln b/sdk/storageactions/Azure.ResourceManager.Storageactions/Azure.ResourceManager.Storageactions.sln new file mode 100644 index 000000000000..d8567d4ed8ea --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/Azure.ResourceManager.Storageactions.sln @@ -0,0 +1,65 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30309.148 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{6D89A781-6B80-4FEF-A320-0160A6A6D8BC}") = "Azure.ResourceManager.Storageactions", "src\Azure.ResourceManager.Storageactions.csproj", "{70B91AB8-C649-420D-8630-B77D3293112B}" +EndProject +Project("{6D89A781-6B80-4FEF-A320-0160A6A6D8BC}") = "Azure.ResourceManager.Storageactions.Tests", "tests\Azure.ResourceManager.Storageactions.Tests.csproj", "{5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}" +EndProject +Project("{6D89A781-6B80-4FEF-A320-0160A6A6D8BC}") = "Azure.ResourceManager.Storageactions.Samples", "samples\Azure.ResourceManager.Storageactions.Samples.csproj", "{7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}" +EndProject +Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2D4F7877-F9F8-4B4F-BA37-64E465626A9B} + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {70B91AB8-C649-420D-8630-B77D3293112B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70B91AB8-C649-420D-8630-B77D3293112B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70B91AB8-C649-420D-8630-B77D3293112B}.Debug|x64.ActiveCfg = Debug|Any CPU + {70B91AB8-C649-420D-8630-B77D3293112B}.Debug|x64.Build.0 = Debug|Any CPU + {70B91AB8-C649-420D-8630-B77D3293112B}.Debug|x86.ActiveCfg = Debug|Any CPU + {70B91AB8-C649-420D-8630-B77D3293112B}.Debug|x86.Build.0 = Debug|Any CPU + {70B91AB8-C649-420D-8630-B77D3293112B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70B91AB8-C649-420D-8630-B77D3293112B}.Release|Any CPU.Build.0 = Release|Any CPU + {70B91AB8-C649-420D-8630-B77D3293112B}.Release|x64.ActiveCfg = Release|Any CPU + {70B91AB8-C649-420D-8630-B77D3293112B}.Release|x64.Build.0 = Release|Any CPU + {70B91AB8-C649-420D-8630-B77D3293112B}.Release|x86.ActiveCfg = Release|Any CPU + {70B91AB8-C649-420D-8630-B77D3293112B}.Release|x86.Build.0 = Release|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Debug|x64.ActiveCfg = Debug|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Debug|x64.Build.0 = Debug|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Debug|x86.ActiveCfg = Debug|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Debug|x86.Build.0 = Debug|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Release|Any CPU.Build.0 = Release|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Release|x64.ActiveCfg = Release|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Release|x64.Build.0 = Release|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Release|x86.ActiveCfg = Release|Any CPU + {5DC2AEF9-B3A7-4B78-BBF3-C23EBB8FDE6C}.Release|x86.Build.0 = Release|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Debug|x64.ActiveCfg = Debug|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Debug|x64.Build.0 = Debug|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Debug|x86.ActiveCfg = Debug|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Debug|x86.Build.0 = Debug|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Release|Any CPU.Build.0 = Release|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Release|x64.ActiveCfg = Release|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Release|x64.Build.0 = Release|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Release|x86.ActiveCfg = Release|Any CPU + {7B0F14E7-5B00-4B8A-9D2A-8FC2C271CD46}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/CHANGELOG.md b/sdk/storageactions/Azure.ResourceManager.Storageactions/CHANGELOG.md new file mode 100644 index 000000000000..23f86d1e896e --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/CHANGELOG.md @@ -0,0 +1,17 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### General New Features + +This package follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +This package is a Public Preview version, so expect incompatible changes in subsequent releases as we improve the product. To provide feedback, submit an issue in our [Azure SDK for .NET GitHub repo](https://github.com/Azure/azure-sdk-for-net/issues). + +> NOTE: For more information about unified authentication, please refer to [Microsoft Azure Identity documentation for .NET](https://docs.microsoft.com//dotnet/api/overview/azure/identity-readme?view=azure-dotnet). \ No newline at end of file diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/Directory.Build.props b/sdk/storageactions/Azure.ResourceManager.Storageactions/Directory.Build.props new file mode 100644 index 000000000000..1a9611bd4924 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/README.md b/sdk/storageactions/Azure.ResourceManager.Storageactions/README.md new file mode 100644 index 000000000000..028b6c00dc12 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure storageactions management client library for .NET + +**[Describe the service briefly first.]** + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Microsoft Azure storageactions management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.Storageactions --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://docs.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ \ No newline at end of file diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/api/Azure.ResourceManager.Storageactions.netstandard2.0.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/api/Azure.ResourceManager.Storageactions.netstandard2.0.cs new file mode 100644 index 000000000000..20d98a894881 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/api/Azure.ResourceManager.Storageactions.netstandard2.0.cs @@ -0,0 +1,290 @@ +namespace Azure.ResourceManager.Storageactions +{ + public static partial class StorageactionsExtensions + { + public static Azure.Response GetStorageTask(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string storageTaskName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetStorageTaskAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string storageTaskName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.Storageactions.StorageTaskResource GetStorageTaskResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.Storageactions.StorageTaskCollection GetStorageTasks(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } + public static Azure.Pageable GetStorageTasks(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetStorageTasksAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response PreviewActionsStorageTask(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, Azure.ResourceManager.Storageactions.Models.StorageTaskPreviewAction storageTaskPreviewAction, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> PreviewActionsStorageTaskAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, Azure.ResourceManager.Storageactions.Models.StorageTaskPreviewAction storageTaskPreviewAction, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class StorageTaskCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected StorageTaskCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string storageTaskName, Azure.ResourceManager.Storageactions.StorageTaskData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string storageTaskName, Azure.ResourceManager.Storageactions.StorageTaskData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string storageTaskName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string storageTaskName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string storageTaskName, 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 storageTaskName, 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 StorageTaskData : Azure.ResourceManager.Models.TrackedResourceData + { + public StorageTaskData(Azure.Core.AzureLocation location) : base (default(Azure.Core.AzureLocation)) { } + public Azure.ResourceManager.Storageactions.Models.StorageTaskAction Action { get { throw null; } set { } } + public System.DateTimeOffset? CreationTimeInUtc { get { throw null; } } + public string Description { get { throw null; } set { } } + public bool? Enabled { get { throw null; } set { } } + public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } + public Azure.ResourceManager.Storageactions.Models.ProvisioningState? ProvisioningState { get { throw null; } } + public long? TaskVersion { get { throw null; } } + } + public partial class StorageTaskResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected StorageTaskResource() { } + public virtual Azure.ResourceManager.Storageactions.StorageTaskData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string storageTaskName) { 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.Pageable GetStorageTaskAssignments(string maxpagesize = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetStorageTaskAssignmentsAsync(string maxpagesize = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetStorageTasksReports(string maxpagesize = null, string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetStorageTasksReportsAsync(string maxpagesize = null, string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.Storageactions.Models.StorageTaskPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Storageactions.Models.StorageTaskPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } +} +namespace Azure.ResourceManager.Storageactions.Models +{ + public static partial class ArmStorageactionsModelFactory + { + public static Azure.ResourceManager.Storageactions.StorageTaskData StorageTaskData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.Models.ManagedServiceIdentity identity = null, long? taskVersion = default(long?), bool? enabled = default(bool?), string description = null, Azure.ResourceManager.Storageactions.Models.StorageTaskAction action = null, Azure.ResourceManager.Storageactions.Models.ProvisioningState? provisioningState = default(Azure.ResourceManager.Storageactions.Models.ProvisioningState?), System.DateTimeOffset? creationTimeInUtc = default(System.DateTimeOffset?)) { throw null; } + public static Azure.ResourceManager.Storageactions.Models.StorageTaskPreviewBlobProperties StorageTaskPreviewBlobProperties(string name = null, System.Collections.Generic.IEnumerable properties = null, System.Collections.Generic.IEnumerable metadata = null, System.Collections.Generic.IEnumerable tags = null, Azure.ResourceManager.Storageactions.Models.MatchedBlockName? matchedBlock = default(Azure.ResourceManager.Storageactions.Models.MatchedBlockName?)) { throw null; } + public static Azure.ResourceManager.Storageactions.Models.StorageTaskReportInstance StorageTaskReportInstance(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.Storageactions.Models.StorageTaskReportProperties properties = null) { throw null; } + public static Azure.ResourceManager.Storageactions.Models.StorageTaskReportProperties StorageTaskReportProperties(Azure.Core.ResourceIdentifier taskAssignmentId = null, Azure.Core.ResourceIdentifier storageAccountId = null, string startTime = null, string finishTime = null, string objectsTargetedCount = null, string objectsOperatedOnCount = null, string objectFailedCount = null, string objectsSucceededCount = null, string runStatusError = null, Azure.ResourceManager.Storageactions.Models.RunStatusEnum? runStatusEnum = default(Azure.ResourceManager.Storageactions.Models.RunStatusEnum?), string summaryReportPath = null, Azure.Core.ResourceIdentifier taskId = null, string taskVersion = null, Azure.ResourceManager.Storageactions.Models.RunResult? runResult = default(Azure.ResourceManager.Storageactions.Models.RunResult?)) { throw null; } + } + public partial class IfCondition + { + public IfCondition(string condition, System.Collections.Generic.IEnumerable operations) { } + public string Condition { get { throw null; } set { } } + public System.Collections.Generic.IList Operations { get { throw null; } } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct MatchedBlockName : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public MatchedBlockName(string value) { throw null; } + public static Azure.ResourceManager.Storageactions.Models.MatchedBlockName Else { get { throw null; } } + public static Azure.ResourceManager.Storageactions.Models.MatchedBlockName If { get { throw null; } } + public static Azure.ResourceManager.Storageactions.Models.MatchedBlockName None { get { throw null; } } + public bool Equals(Azure.ResourceManager.Storageactions.Models.MatchedBlockName other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.Storageactions.Models.MatchedBlockName left, Azure.ResourceManager.Storageactions.Models.MatchedBlockName right) { throw null; } + public static implicit operator Azure.ResourceManager.Storageactions.Models.MatchedBlockName (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Storageactions.Models.MatchedBlockName left, Azure.ResourceManager.Storageactions.Models.MatchedBlockName right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct OnFailure : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public OnFailure(string value) { throw null; } + public static Azure.ResourceManager.Storageactions.Models.OnFailure Break { get { throw null; } } + public bool Equals(Azure.ResourceManager.Storageactions.Models.OnFailure other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.Storageactions.Models.OnFailure left, Azure.ResourceManager.Storageactions.Models.OnFailure right) { throw null; } + public static implicit operator Azure.ResourceManager.Storageactions.Models.OnFailure (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Storageactions.Models.OnFailure left, Azure.ResourceManager.Storageactions.Models.OnFailure right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct OnSuccess : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public OnSuccess(string value) { throw null; } + public static Azure.ResourceManager.Storageactions.Models.OnSuccess Continue { get { throw null; } } + public bool Equals(Azure.ResourceManager.Storageactions.Models.OnSuccess other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.Storageactions.Models.OnSuccess left, Azure.ResourceManager.Storageactions.Models.OnSuccess right) { throw null; } + public static implicit operator Azure.ResourceManager.Storageactions.Models.OnSuccess (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Storageactions.Models.OnSuccess left, Azure.ResourceManager.Storageactions.Models.OnSuccess right) { throw null; } + public override string ToString() { throw null; } + } + public enum ProvisioningState + { + ValidateSubscriptionQuotaBegin = 0, + ValidateSubscriptionQuotaEnd = 1, + Creating = 2, + Succeeded = 3, + Deleting = 4, + Canceled = 5, + Failed = 6, + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct RunResult : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public RunResult(string value) { throw null; } + public static Azure.ResourceManager.Storageactions.Models.RunResult Failed { get { throw null; } } + public static Azure.ResourceManager.Storageactions.Models.RunResult Succeeded { get { throw null; } } + public bool Equals(Azure.ResourceManager.Storageactions.Models.RunResult other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.Storageactions.Models.RunResult left, Azure.ResourceManager.Storageactions.Models.RunResult right) { throw null; } + public static implicit operator Azure.ResourceManager.Storageactions.Models.RunResult (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Storageactions.Models.RunResult left, Azure.ResourceManager.Storageactions.Models.RunResult right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct RunStatusEnum : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public RunStatusEnum(string value) { throw null; } + public static Azure.ResourceManager.Storageactions.Models.RunStatusEnum Finished { get { throw null; } } + public static Azure.ResourceManager.Storageactions.Models.RunStatusEnum InProgress { get { throw null; } } + public bool Equals(Azure.ResourceManager.Storageactions.Models.RunStatusEnum other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.Storageactions.Models.RunStatusEnum left, Azure.ResourceManager.Storageactions.Models.RunStatusEnum right) { throw null; } + public static implicit operator Azure.ResourceManager.Storageactions.Models.RunStatusEnum (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Storageactions.Models.RunStatusEnum left, Azure.ResourceManager.Storageactions.Models.RunStatusEnum right) { throw null; } + public override string ToString() { throw null; } + } + public partial class StorageTaskAction + { + public StorageTaskAction(Azure.ResourceManager.Storageactions.Models.IfCondition @if) { } + public System.Collections.Generic.IList ElseOperations { get { throw null; } set { } } + public Azure.ResourceManager.Storageactions.Models.IfCondition If { get { throw null; } set { } } + } + public partial class StorageTaskOperation + { + public StorageTaskOperation(Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName name) { } + public Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName Name { get { throw null; } set { } } + public Azure.ResourceManager.Storageactions.Models.OnFailure? OnFailure { get { throw null; } set { } } + public Azure.ResourceManager.Storageactions.Models.OnSuccess? OnSuccess { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Parameters { get { throw null; } } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct StorageTaskOperationName : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public StorageTaskOperationName(string value) { throw null; } + public static Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName DeleteBlob { get { throw null; } } + public static Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName SetBlobExpiry { get { throw null; } } + public static Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName SetBlobImmutabilityPolicy { get { throw null; } } + public static Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName SetBlobLegalHold { get { throw null; } } + public static Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName SetBlobTags { get { throw null; } } + public static Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName SetBlobTier { get { throw null; } } + public static Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName UndeleteBlob { get { throw null; } } + public bool Equals(Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName left, Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName right) { throw null; } + public static implicit operator Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName left, Azure.ResourceManager.Storageactions.Models.StorageTaskOperationName right) { throw null; } + public override string ToString() { throw null; } + } + public partial class StorageTaskPatch + { + public StorageTaskPatch() { } + public Azure.ResourceManager.Storageactions.Models.StorageTaskAction Action { get { throw null; } set { } } + public System.DateTimeOffset? CreationTimeInUtc { get { throw null; } } + public string Description { get { throw null; } set { } } + public bool? Enabled { get { throw null; } set { } } + public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } + public Azure.ResourceManager.Storageactions.Models.ProvisioningState? ProvisioningState { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public long? TaskVersion { get { throw null; } } + } + public partial class StorageTaskPreviewAction + { + public StorageTaskPreviewAction(Azure.ResourceManager.Storageactions.Models.StorageTaskPreviewContainerProperties container, System.Collections.Generic.IEnumerable blobs, Azure.ResourceManager.Storageactions.Models.StorageTaskPreviewActionCondition action) { } + public Azure.ResourceManager.Storageactions.Models.StorageTaskPreviewActionCondition Action { get { throw null; } set { } } + public System.Collections.Generic.IList Blobs { get { throw null; } } + public Azure.ResourceManager.Storageactions.Models.StorageTaskPreviewContainerProperties Container { get { throw null; } set { } } + } + public partial class StorageTaskPreviewActionCondition + { + public StorageTaskPreviewActionCondition(Azure.ResourceManager.Storageactions.Models.StorageTaskPreviewActionIfCondition @if, bool elseBlockExists) { } + public bool ElseBlockExists { get { throw null; } set { } } + public string IfCondition { get { throw null; } set { } } + } + public partial class StorageTaskPreviewActionIfCondition + { + public StorageTaskPreviewActionIfCondition() { } + public string Condition { get { throw null; } set { } } + } + public partial class StorageTaskPreviewBlobProperties + { + public StorageTaskPreviewBlobProperties() { } + public Azure.ResourceManager.Storageactions.Models.MatchedBlockName? MatchedBlock { get { throw null; } } + public System.Collections.Generic.IList Metadata { get { throw null; } } + public string Name { get { throw null; } set { } } + public System.Collections.Generic.IList Properties { get { throw null; } } + public System.Collections.Generic.IList Tags { get { throw null; } } + } + public partial class StorageTaskPreviewContainerProperties + { + public StorageTaskPreviewContainerProperties() { } + public System.Collections.Generic.IList Metadata { get { throw null; } } + public string Name { get { throw null; } set { } } + } + public partial class StorageTaskPreviewKeyValueProperties + { + public StorageTaskPreviewKeyValueProperties() { } + public string Key { get { throw null; } set { } } + public string Value { get { throw null; } set { } } + } + public partial class StorageTaskReportInstance : Azure.ResourceManager.Models.ResourceData + { + public StorageTaskReportInstance() { } + public Azure.ResourceManager.Storageactions.Models.StorageTaskReportProperties Properties { get { throw null; } set { } } + } + public partial class StorageTaskReportProperties + { + public StorageTaskReportProperties() { } + public string FinishTime { get { throw null; } } + public string ObjectFailedCount { get { throw null; } } + public string ObjectsOperatedOnCount { get { throw null; } } + public string ObjectsSucceededCount { get { throw null; } } + public string ObjectsTargetedCount { get { throw null; } } + public Azure.ResourceManager.Storageactions.Models.RunResult? RunResult { get { throw null; } } + public Azure.ResourceManager.Storageactions.Models.RunStatusEnum? RunStatusEnum { get { throw null; } } + public string RunStatusError { get { throw null; } } + public string StartTime { get { throw null; } } + public Azure.Core.ResourceIdentifier StorageAccountId { get { throw null; } } + public string SummaryReportPath { get { throw null; } } + public Azure.Core.ResourceIdentifier TaskAssignmentId { get { throw null; } } + public Azure.Core.ResourceIdentifier TaskId { get { throw null; } } + public string TaskVersion { get { throw null; } } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/assets.json b/sdk/storageactions/Azure.ResourceManager.Storageactions/assets.json new file mode 100644 index 000000000000..c081239e19e8 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net//Azure.ResourceManager.Storageactions", + "Tag": "" +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/samples/Azure.ResourceManager.Storageactions.Samples.csproj b/sdk/storageactions/Azure.ResourceManager.Storageactions/samples/Azure.ResourceManager.Storageactions.Samples.csproj new file mode 100644 index 000000000000..42cbcef92121 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/samples/Azure.ResourceManager.Storageactions.Samples.csproj @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/samples/Generated/Samples/Sample_StorageTaskCollection.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/samples/Generated/Samples/Sample_StorageTaskCollection.cs new file mode 100644 index 000000000000..27ee80a1efca --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/samples/Generated/Samples/Sample_StorageTaskCollection.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Storageactions; +using Azure.ResourceManager.Storageactions.Models; + +namespace Azure.ResourceManager.Storageactions.Samples +{ + public partial class Sample_StorageTaskCollection + { + // PutStorageTask + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_PutStorageTask() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/PutStorageTask.json + // this example is just showing the usage of "StorageTasks_Create" 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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + string resourceGroupName = "res4228"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this StorageTaskResource + StorageTaskCollection collection = resourceGroupResource.GetStorageTasks(); + + // invoke the operation + string storageTaskName = "mytask1"; + StorageTaskData data = new StorageTaskData(new AzureLocation("westus")) + { + Enabled = true, + Description = "My Storage task", + Action = new StorageTaskAction(new IfCondition("[[equals(AccessTier, 'Cool')]]", new StorageTaskOperation[] + { +new StorageTaskOperation(StorageTaskOperationName.SetBlobTier) +{ +Parameters = +{ +["tier"] = "Hot", +}, +OnSuccess = OnSuccess.Continue, +OnFailure = OnFailure.Break, +} + })) + { + ElseOperations = +{ +new StorageTaskOperation(StorageTaskOperationName.DeleteBlob) +{ +OnSuccess = OnSuccess.Continue, +OnFailure = OnFailure.Break, +} +}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageTaskName, data); + StorageTaskResource result = lro.Value; + + // the variable result 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 + StorageTaskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // GetStorageTask + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetStorageTask() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/GetStorageTask.json + // this example is just showing the usage of "StorageTasks_Get" 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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + string resourceGroupName = "res4228"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this StorageTaskResource + StorageTaskCollection collection = resourceGroupResource.GetStorageTasks(); + + // invoke the operation + string storageTaskName = "mytask1"; + StorageTaskResource result = await collection.GetAsync(storageTaskName); + + // the variable result 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 + StorageTaskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // GetStorageTask + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetStorageTask() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/GetStorageTask.json + // this example is just showing the usage of "StorageTasks_Get" 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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + string resourceGroupName = "res4228"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this StorageTaskResource + StorageTaskCollection collection = resourceGroupResource.GetStorageTasks(); + + // invoke the operation + string storageTaskName = "mytask1"; + bool result = await collection.ExistsAsync(storageTaskName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ListStorageTasksByResourceGroup + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListStorageTasksByResourceGroup() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksList/ListStorageTasksByResourceGroup.json + // this example is just showing the usage of "StorageTasks_ListByResourceGroup" 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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + string resourceGroupName = "res6117"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this StorageTaskResource + StorageTaskCollection collection = resourceGroupResource.GetStorageTasks(); + + // invoke the operation and iterate over the result + await foreach (StorageTaskResource item in collection.GetAllAsync()) + { + // 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 + StorageTaskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/samples/Generated/Samples/Sample_StorageTaskResource.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/samples/Generated/Samples/Sample_StorageTaskResource.cs new file mode 100644 index 000000000000..8381353fa44c --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/samples/Generated/Samples/Sample_StorageTaskResource.cs @@ -0,0 +1,406 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.Storageactions; +using Azure.ResourceManager.Storageactions.Models; + +namespace Azure.ResourceManager.Storageactions.Samples +{ + public partial class Sample_StorageTaskResource + { + // DeleteStorageTask + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteStorageTask() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/DeleteStorageTask.json + // this example is just showing the usage of "StorageTasks_Delete" 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 StorageTaskResource created on azure + // for more information of creating StorageTaskResource, please refer to the document of StorageTaskResource + string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + string resourceGroupName = "res4228"; + string storageTaskName = "mytask1"; + ResourceIdentifier storageTaskResourceId = StorageTaskResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, storageTaskName); + StorageTaskResource storageTask = client.GetStorageTaskResource(storageTaskResourceId); + + // invoke the operation + await storageTask.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // GetStorageTask + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetStorageTask() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/GetStorageTask.json + // this example is just showing the usage of "StorageTasks_Get" 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 StorageTaskResource created on azure + // for more information of creating StorageTaskResource, please refer to the document of StorageTaskResource + string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + string resourceGroupName = "res4228"; + string storageTaskName = "mytask1"; + ResourceIdentifier storageTaskResourceId = StorageTaskResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, storageTaskName); + StorageTaskResource storageTask = client.GetStorageTaskResource(storageTaskResourceId); + + // invoke the operation + StorageTaskResource result = await storageTask.GetAsync(); + + // the variable result 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 + StorageTaskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // PatchStorageTask + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_PatchStorageTask() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/PatchStorageTask.json + // this example is just showing the usage of "StorageTasks_Update" 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 StorageTaskResource created on azure + // for more information of creating StorageTaskResource, please refer to the document of StorageTaskResource + string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + string resourceGroupName = "res4228"; + string storageTaskName = "mytask1"; + ResourceIdentifier storageTaskResourceId = StorageTaskResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, storageTaskName); + StorageTaskResource storageTask = client.GetStorageTaskResource(storageTaskResourceId); + + // invoke the operation + StorageTaskPatch patch = new StorageTaskPatch() + { + Enabled = true, + Description = "My Storage task", + Action = new StorageTaskAction(new IfCondition("[[equals(AccessTier, 'Cool')]]", new StorageTaskOperation[] + { +new StorageTaskOperation(StorageTaskOperationName.SetBlobTier) +{ +Parameters = +{ +["tier"] = "Hot", +}, +OnSuccess = OnSuccess.Continue, +OnFailure = OnFailure.Break, +} + })) + { + ElseOperations = +{ +new StorageTaskOperation(StorageTaskOperationName.DeleteBlob) +{ +OnSuccess = OnSuccess.Continue, +OnFailure = OnFailure.Break, +} +}, + }, + }; + ArmOperation lro = await storageTask.UpdateAsync(WaitUntil.Completed, patch); + StorageTaskResource result = lro.Value; + + // the variable result 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 + StorageTaskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ListStorageTasksBySubscription + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetStorageTasks_ListStorageTasksBySubscription() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksList/ListStorageTasksBySubscription.json + // this example is just showing the usage of "StorageTasks_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 = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (StorageTaskResource item in subscriptionResource.GetStorageTasksAsync()) + { + // 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 + StorageTaskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // PerformStorageTaskActionsPreview + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task PreviewActionsStorageTask_PerformStorageTaskActionsPreview() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/misc/PerformStorageTaskActionsPreview.json + // this example is just showing the usage of "StorageTasks_PreviewActions" 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 = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("eastus"); + StorageTaskPreviewAction storageTaskPreviewAction = new StorageTaskPreviewAction(new StorageTaskPreviewContainerProperties() + { + Name = "firstContainer", + Metadata = +{ +new StorageTaskPreviewKeyValueProperties() +{ +Key = "mContainerKey1", +Value = "mContainerValue1", +} +}, + }, new StorageTaskPreviewBlobProperties[] + { +new StorageTaskPreviewBlobProperties() +{ +Name = "folder1/file1.txt", +Properties = +{ +new StorageTaskPreviewKeyValueProperties() +{ +Key = "Creation-Time", +Value = "Wed, 07 Jun 2023 05:23:29 GMT", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Last-Modified", +Value = "Wed, 07 Jun 2023 05:23:29 GMT", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Etag", +Value = "0x8DB67175454D36D", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Content-Length", +Value = "38619", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Content-Type", +Value = "text/xml", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Content-Encoding", +Value = "", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Content-Language", +Value = "", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Content-CRC64", +Value = "", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Content-MD5", +Value = "njr6iDrmU9+FC89WMK22EA==", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Cache-Control", +Value = "", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Content-Disposition", +Value = "", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "BlobType", +Value = "BlockBlob", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "AccessTier", +Value = "Hot", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "AccessTierInferred", +Value = "true", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "LeaseStatus", +Value = "unlocked", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "LeaseState", +Value = "available", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "ServerEncrypted", +Value = "true", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "TagCount", +Value = "1", +} +}, +Metadata = +{ +new StorageTaskPreviewKeyValueProperties() +{ +Key = "mKey1", +Value = "mValue1", +} +}, +Tags = +{ +new StorageTaskPreviewKeyValueProperties() +{ +Key = "tKey1", +Value = "tValue1", +} +}, +},new StorageTaskPreviewBlobProperties() +{ +Name = "folder2/file1.txt", +Properties = +{ +new StorageTaskPreviewKeyValueProperties() +{ +Key = "Creation-Time", +Value = "Wed, 06 Jun 2023 05:23:29 GMT", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Last-Modified", +Value = "Wed, 06 Jun 2023 05:23:29 GMT", +},new StorageTaskPreviewKeyValueProperties() +{ +Key = "Etag", +Value = "0x6FB67175454D36D", +} +}, +Metadata = +{ +new StorageTaskPreviewKeyValueProperties() +{ +Key = "mKey2", +Value = "mValue2", +} +}, +Tags = +{ +new StorageTaskPreviewKeyValueProperties() +{ +Key = "tKey2", +Value = "tValue2", +} +}, +} + }, new StorageTaskPreviewActionCondition(new StorageTaskPreviewActionIfCondition() + { + Condition = "[[equals(AccessTier, 'Hot')]]", + }, true)); + StorageTaskPreviewAction result = await subscriptionResource.PreviewActionsStorageTaskAsync(location, storageTaskPreviewAction); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ListStorageTaskAssignmentsByResourceGroup + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetStorageTaskAssignments_ListStorageTaskAssignmentsByResourceGroup() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksList/ListStorageTaskAssignmentIds.json + // this example is just showing the usage of "StorageTaskAssignment_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 StorageTaskResource created on azure + // for more information of creating StorageTaskResource, please refer to the document of StorageTaskResource + string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + string resourceGroupName = "rgroup1"; + string storageTaskName = "mytask1"; + ResourceIdentifier storageTaskResourceId = StorageTaskResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, storageTaskName); + StorageTaskResource storageTask = client.GetStorageTaskResource(storageTaskResourceId); + + // invoke the operation and iterate over the result + await foreach (SubResource item in storageTask.GetStorageTaskAssignmentsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // ListStorageTasksByResourceGroup + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetStorageTasksReports_ListStorageTasksByResourceGroup() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksList/ListStorageTasksRunReportSummary.json + // this example is just showing the usage of "StorageTasksReport_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 StorageTaskResource created on azure + // for more information of creating StorageTaskResource, please refer to the document of StorageTaskResource + string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + string resourceGroupName = "rgroup1"; + string storageTaskName = "mytask1"; + ResourceIdentifier storageTaskResourceId = StorageTaskResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, storageTaskName); + StorageTaskResource storageTask = client.GetStorageTaskResource(storageTaskResourceId); + + // invoke the operation and iterate over the result + await foreach (StorageTaskReportInstance item in storageTask.GetStorageTasksReportsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Azure.ResourceManager.Storageactions.csproj b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Azure.ResourceManager.Storageactions.csproj new file mode 100644 index 000000000000..36c1e68220e6 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Azure.ResourceManager.Storageactions.csproj @@ -0,0 +1,8 @@ + + + 1.0.0-beta.1 + Azure.ResourceManager.Storageactions + Azure Resource Manager client SDK for Azure resource provider storageactions. + azure;management;arm;resource manager;storageactions + + diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/ArmStorageactionsModelFactory.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/ArmStorageactionsModelFactory.cs new file mode 100644 index 000000000000..692a26f5dca3 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/ArmStorageactionsModelFactory.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Storageactions; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Model factory for models. + public static partial class ArmStorageactionsModelFactory + { + /// Initializes a new instance of StorageTaskData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The managed service identity of the resource. + /// Storage task version. + /// Storage Task is enabled when set to true and disabled when set to false. + /// Text that describes the purpose of the storage task. + /// The storage task action that is executed. + /// Represents the provisioning state of the storage task. + /// The creation date and time of the storage task in UTC. + /// A new instance for mocking. + public static StorageTaskData StorageTaskData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ManagedServiceIdentity identity = null, long? taskVersion = null, bool? enabled = null, string description = null, StorageTaskAction action = null, ProvisioningState? provisioningState = null, DateTimeOffset? creationTimeInUtc = null) + { + tags ??= new Dictionary(); + + return new StorageTaskData(id, name, resourceType, systemData, tags, location, identity, taskVersion, enabled, description, action, provisioningState, creationTimeInUtc); + } + + /// Initializes a new instance of StorageTaskReportInstance. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Storage task execution report for a run instance. + /// A new instance for mocking. + public static StorageTaskReportInstance StorageTaskReportInstance(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, StorageTaskReportProperties properties = null) + { + return new StorageTaskReportInstance(id, name, resourceType, systemData, properties); + } + + /// Initializes a new instance of StorageTaskReportProperties. + /// Represents the Storage Task Assignment Id associated with the storage task that provided an execution context. + /// Represents the Storage Account Id where the storage task definition was applied and executed. + /// Start time of the run instance. Filter options such as startTime gt '2023-06-26T20:51:24.4494016Z' and other comparison operators can be used as described for DateTime properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// End time of the run instance. Filter options such as startTime gt '2023-06-26T20:51:24.4494016Z' and other comparison operators can be used as described for DateTime properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// Total number of objects that meet the condition as defined in the storage task assignment execution context. Filter options such as objectsTargetedCount gt 50 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// Total number of objects that meet the storage tasks condition and were operated upon. Filter options such as objectsOperatedOnCount ge 100 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// Total number of objects where task operation failed when was attempted. Filter options such as objectFailedCount eq 0 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// Total number of objects where task operation succeeded when was attempted.Filter options such as objectsSucceededCount gt 150 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// Well known Azure Storage error code that represents the error encountered during execution of the run instance. + /// Represents the status of the execution. + /// Full path to the verbose report stored in the reporting container as specified in the assignment execution context for the storage account. + /// Storage Task Arm Id. + /// Storage Task Version. + /// Represents the overall result of the execution for the run instance. + /// A new instance for mocking. + public static StorageTaskReportProperties StorageTaskReportProperties(ResourceIdentifier taskAssignmentId = null, ResourceIdentifier storageAccountId = null, string startTime = null, string finishTime = null, string objectsTargetedCount = null, string objectsOperatedOnCount = null, string objectFailedCount = null, string objectsSucceededCount = null, string runStatusError = null, RunStatusEnum? runStatusEnum = null, string summaryReportPath = null, ResourceIdentifier taskId = null, string taskVersion = null, RunResult? runResult = null) + { + return new StorageTaskReportProperties(taskAssignmentId, storageAccountId, startTime, finishTime, objectsTargetedCount, objectsOperatedOnCount, objectFailedCount, objectsSucceededCount, runStatusError, runStatusEnum, summaryReportPath, taskId, taskVersion, runResult); + } + + /// Initializes a new instance of StorageTaskPreviewBlobProperties. + /// property for the container name. + /// properties key value pairs to be tested for a match against the provided condition. + /// metadata key value pairs to be tested for a match against the provided condition. + /// tags key value pairs to be tested for a match against the provided condition. + /// Represents the condition block name that matched blob properties. + /// A new instance for mocking. + public static StorageTaskPreviewBlobProperties StorageTaskPreviewBlobProperties(string name = null, IEnumerable properties = null, IEnumerable metadata = null, IEnumerable tags = null, MatchedBlockName? matchedBlock = null) + { + properties ??= new List(); + metadata ??= new List(); + tags ??= new List(); + + return new StorageTaskPreviewBlobProperties(name, properties?.ToList(), metadata?.ToList(), tags?.ToList(), matchedBlock); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs new file mode 100644 index 000000000000..303a67298273 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Storageactions +{ + /// A class to add extension methods to ResourceGroupResource. + internal partial class ResourceGroupResourceExtensionClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected ResourceGroupResourceExtensionClient() + { + } + + /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of StorageTaskResources in the ResourceGroupResource. + /// An object representing collection of StorageTaskResources and their operations over a StorageTaskResource. + public virtual StorageTaskCollection GetStorageTasks() + { + return GetCachedClient(Client => new StorageTaskCollection(Client, Id)); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Extensions/StorageactionsExtensions.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Extensions/StorageactionsExtensions.cs new file mode 100644 index 000000000000..46e90d72b033 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Extensions/StorageactionsExtensions.cs @@ -0,0 +1,220 @@ +// 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.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Storageactions.Models; + +namespace Azure.ResourceManager.Storageactions +{ + /// A class to add extension methods to Azure.ResourceManager.Storageactions. + public static partial class StorageactionsExtensions + { + private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + { + return resource.GetCachedClient(client => + { + return new ResourceGroupResourceExtensionClient(client, resource.Id); + }); + } + + private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + { + return client.GetResourceClient(() => + { + return new ResourceGroupResourceExtensionClient(client, scope); + }); + } + + private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + { + return resource.GetCachedClient(client => + { + return new SubscriptionResourceExtensionClient(client, resource.Id); + }); + } + + private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + { + return client.GetResourceClient(() => + { + return new SubscriptionResourceExtensionClient(client, scope); + }); + } + #region StorageTaskResource + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static StorageTaskResource GetStorageTaskResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + StorageTaskResource.ValidateResourceId(id); + return new StorageTaskResource(client, id); + } + ); + } + #endregion + + /// Gets a collection of StorageTaskResources in the ResourceGroupResource. + /// The instance the method will execute against. + /// An object representing collection of StorageTaskResources and their operations over a StorageTaskResource. + public static StorageTaskCollection GetStorageTasks(this ResourceGroupResource resourceGroupResource) + { + return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetStorageTasks(); + } + + /// + /// Get the storage task properties + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The instance the method will execute against. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public static async Task> GetStorageTaskAsync(this ResourceGroupResource resourceGroupResource, string storageTaskName, CancellationToken cancellationToken = default) + { + return await resourceGroupResource.GetStorageTasks().GetAsync(storageTaskName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get the storage task properties + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The instance the method will execute against. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public static Response GetStorageTask(this ResourceGroupResource resourceGroupResource, string storageTaskName, CancellationToken cancellationToken = default) + { + return resourceGroupResource.GetStorageTasks().Get(storageTaskName, cancellationToken); + } + + /// + /// Lists all the storage tasks available under the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.StorageActions/storageTasks + /// + /// + /// Operation Id + /// StorageTasks_ListBySubscription + /// + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetStorageTasksAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + return GetSubscriptionResourceExtensionClient(subscriptionResource).GetStorageTasksAsync(cancellationToken); + } + + /// + /// Lists all the storage tasks available under the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.StorageActions/storageTasks + /// + /// + /// Operation Id + /// StorageTasks_ListBySubscription + /// + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetStorageTasks(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + return GetSubscriptionResourceExtensionClient(subscriptionResource).GetStorageTasks(cancellationToken); + } + + /// + /// Runs the input conditions against input object metadata properties and designates matched objects in response. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.StorageActions/locations/{location}/previewActions + /// + /// + /// Operation Id + /// StorageTasks_PreviewActions + /// + /// + /// + /// The instance the method will execute against. + /// The location to perform preview of the actions. + /// The parameters to preview action condition. + /// The cancellation token to use. + /// is null. + public static async Task> PreviewActionsStorageTaskAsync(this SubscriptionResource subscriptionResource, AzureLocation location, StorageTaskPreviewAction storageTaskPreviewAction, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(storageTaskPreviewAction, nameof(storageTaskPreviewAction)); + + return await GetSubscriptionResourceExtensionClient(subscriptionResource).PreviewActionsStorageTaskAsync(location, storageTaskPreviewAction, cancellationToken).ConfigureAwait(false); + } + + /// + /// Runs the input conditions against input object metadata properties and designates matched objects in response. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.StorageActions/locations/{location}/previewActions + /// + /// + /// Operation Id + /// StorageTasks_PreviewActions + /// + /// + /// + /// The instance the method will execute against. + /// The location to perform preview of the actions. + /// The parameters to preview action condition. + /// The cancellation token to use. + /// is null. + public static Response PreviewActionsStorageTask(this SubscriptionResource subscriptionResource, AzureLocation location, StorageTaskPreviewAction storageTaskPreviewAction, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(storageTaskPreviewAction, nameof(storageTaskPreviewAction)); + + return GetSubscriptionResourceExtensionClient(subscriptionResource).PreviewActionsStorageTask(location, storageTaskPreviewAction, cancellationToken); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs new file mode 100644 index 000000000000..257e1d0e261f --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Storageactions.Models; + +namespace Azure.ResourceManager.Storageactions +{ + /// A class to add extension methods to SubscriptionResource. + internal partial class SubscriptionResourceExtensionClient : ArmResource + { + private ClientDiagnostics _storageTaskClientDiagnostics; + private StorageTasksRestOperations _storageTaskRestClient; + + /// Initializes a new instance of the class for mocking. + protected SubscriptionResourceExtensionClient() + { + } + + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics StorageTaskClientDiagnostics => _storageTaskClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Storageactions", StorageTaskResource.ResourceType.Namespace, Diagnostics); + private StorageTasksRestOperations StorageTaskRestClient => _storageTaskRestClient ??= new StorageTasksRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(StorageTaskResource.ResourceType)); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Lists all the storage tasks available under the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.StorageActions/storageTasks + /// + /// + /// Operation Id + /// StorageTasks_ListBySubscription + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetStorageTasksAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => StorageTaskRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => StorageTaskRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new StorageTaskResource(Client, StorageTaskData.DeserializeStorageTaskData(e)), StorageTaskClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetStorageTasks", "value", "nextLink", cancellationToken); + } + + /// + /// Lists all the storage tasks available under the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.StorageActions/storageTasks + /// + /// + /// Operation Id + /// StorageTasks_ListBySubscription + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetStorageTasks(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => StorageTaskRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => StorageTaskRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new StorageTaskResource(Client, StorageTaskData.DeserializeStorageTaskData(e)), StorageTaskClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetStorageTasks", "value", "nextLink", cancellationToken); + } + + /// + /// Runs the input conditions against input object metadata properties and designates matched objects in response. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.StorageActions/locations/{location}/previewActions + /// + /// + /// Operation Id + /// StorageTasks_PreviewActions + /// + /// + /// + /// The location to perform preview of the actions. + /// The parameters to preview action condition. + /// The cancellation token to use. + public virtual async Task> PreviewActionsStorageTaskAsync(AzureLocation location, StorageTaskPreviewAction storageTaskPreviewAction, CancellationToken cancellationToken = default) + { + using var scope = StorageTaskClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.PreviewActionsStorageTask"); + scope.Start(); + try + { + var response = await StorageTaskRestClient.PreviewActionsAsync(Id.SubscriptionId, location, storageTaskPreviewAction, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Runs the input conditions against input object metadata properties and designates matched objects in response. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.StorageActions/locations/{location}/previewActions + /// + /// + /// Operation Id + /// StorageTasks_PreviewActions + /// + /// + /// + /// The location to perform preview of the actions. + /// The parameters to preview action condition. + /// The cancellation token to use. + public virtual Response PreviewActionsStorageTask(AzureLocation location, StorageTaskPreviewAction storageTaskPreviewAction, CancellationToken cancellationToken = default) + { + using var scope = StorageTaskClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.PreviewActionsStorageTask"); + scope.Start(); + try + { + var response = StorageTaskRestClient.PreviewActions(Id.SubscriptionId, location, storageTaskPreviewAction, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/LongRunningOperation/StorageTaskOperationSource.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/LongRunningOperation/StorageTaskOperationSource.cs new file mode 100644 index 000000000000..041ac6950025 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/LongRunningOperation/StorageTaskOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Storageactions +{ + internal class StorageTaskOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal StorageTaskOperationSource(ArmClient client) + { + _client = client; + } + + StorageTaskResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = StorageTaskData.DeserializeStorageTaskData(document.RootElement); + return new StorageTaskResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = StorageTaskData.DeserializeStorageTaskData(document.RootElement); + return new StorageTaskResource(_client, data); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/LongRunningOperation/StorageactionsArmOperation.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/LongRunningOperation/StorageactionsArmOperation.cs new file mode 100644 index 000000000000..d81cc9c9e669 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/LongRunningOperation/StorageactionsArmOperation.cs @@ -0,0 +1,70 @@ +// 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; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Storageactions +{ +#pragma warning disable SA1649 // File name should match first type name + internal class StorageactionsArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + + /// Initializes a new instance of StorageactionsArmOperation for mocking. + protected StorageactionsArmOperation() + { + } + + internal StorageactionsArmOperation(Response response) + { + _operation = OperationInternal.Succeeded(response); + } + + internal StorageactionsArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "StorageactionsArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + /// +#pragma warning disable CA1822 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public override string Id => throw new NotImplementedException(); +#pragma warning restore CA1822 + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); + + /// + public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/LongRunningOperation/StorageactionsArmOperationOfT.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/LongRunningOperation/StorageactionsArmOperationOfT.cs new file mode 100644 index 000000000000..cd98394fcc92 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/LongRunningOperation/StorageactionsArmOperationOfT.cs @@ -0,0 +1,76 @@ +// 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; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Storageactions +{ +#pragma warning disable SA1649 // File name should match first type name + internal class StorageactionsArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + + /// Initializes a new instance of StorageactionsArmOperation for mocking. + protected StorageactionsArmOperation() + { + } + + internal StorageactionsArmOperation(Response response) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + } + + internal StorageactionsArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(source, pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "StorageactionsArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + /// +#pragma warning disable CA1822 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public override string Id => throw new NotImplementedException(); +#pragma warning restore CA1822 + + /// + public override T Value => _operation.Value; + + /// + public override bool HasValue => _operation.HasValue; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); + + /// + public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ElseCondition.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ElseCondition.Serialization.cs new file mode 100644 index 000000000000..e5fce936888e --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ElseCondition.Serialization.cs @@ -0,0 +1,52 @@ +// 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; + +namespace Azure.ResourceManager.Storageactions.Models +{ + internal partial class ElseCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("operations"u8); + writer.WriteStartArray(); + foreach (var item in Operations) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WriteEndObject(); + } + + internal static ElseCondition DeserializeElseCondition(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList operations = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operations"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StorageTaskOperation.DeserializeStorageTaskOperation(item)); + } + operations = array; + continue; + } + } + return new ElseCondition(operations); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ElseCondition.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ElseCondition.cs new file mode 100644 index 000000000000..8051a3f5724c --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ElseCondition.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// The else block of storage task operation. + internal partial class ElseCondition + { + /// Initializes a new instance of ElseCondition. + /// List of operations to execute in the else block. + /// is null. + public ElseCondition(IEnumerable operations) + { + Argument.AssertNotNull(operations, nameof(operations)); + + Operations = operations.ToList(); + } + + /// Initializes a new instance of ElseCondition. + /// List of operations to execute in the else block. + internal ElseCondition(IList operations) + { + Operations = operations; + } + + /// List of operations to execute in the else block. + public IList Operations { get; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/IfCondition.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/IfCondition.Serialization.cs new file mode 100644 index 000000000000..9b59f0c4938c --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/IfCondition.Serialization.cs @@ -0,0 +1,60 @@ +// 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; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class IfCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("condition"u8); + writer.WriteStringValue(Condition); + writer.WritePropertyName("operations"u8); + writer.WriteStartArray(); + foreach (var item in Operations) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WriteEndObject(); + } + + internal static IfCondition DeserializeIfCondition(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string condition = default; + IList operations = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("condition"u8)) + { + condition = property.Value.GetString(); + continue; + } + if (property.NameEquals("operations"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StorageTaskOperation.DeserializeStorageTaskOperation(item)); + } + operations = array; + continue; + } + } + return new IfCondition(condition, operations); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/IfCondition.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/IfCondition.cs new file mode 100644 index 000000000000..e740c87fb512 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/IfCondition.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// The if block of storage task operation. + public partial class IfCondition + { + /// Initializes a new instance of IfCondition. + /// The condition predicate which is composed of object properties, eg: blob and container properties. + /// List of operations to execute when the condition predicate satisfies. + /// or is null. + public IfCondition(string condition, IEnumerable operations) + { + Argument.AssertNotNull(condition, nameof(condition)); + Argument.AssertNotNull(operations, nameof(operations)); + + Condition = condition; + Operations = operations.ToList(); + } + + /// Initializes a new instance of IfCondition. + /// The condition predicate which is composed of object properties, eg: blob and container properties. + /// List of operations to execute when the condition predicate satisfies. + internal IfCondition(string condition, IList operations) + { + Condition = condition; + Operations = operations; + } + + /// The condition predicate which is composed of object properties, eg: blob and container properties. + public string Condition { get; set; } + /// List of operations to execute when the condition predicate satisfies. + public IList Operations { get; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/MatchedBlockName.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/MatchedBlockName.cs new file mode 100644 index 000000000000..616bf59bd2ce --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/MatchedBlockName.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Represents the condition block name that matched blob properties. + public readonly partial struct MatchedBlockName : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MatchedBlockName(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string IfValue = "If"; + private const string ElseValue = "Else"; + private const string NoneValue = "None"; + + /// If. + public static MatchedBlockName If { get; } = new MatchedBlockName(IfValue); + /// Else. + public static MatchedBlockName Else { get; } = new MatchedBlockName(ElseValue); + /// None. + public static MatchedBlockName None { get; } = new MatchedBlockName(NoneValue); + /// Determines if two values are the same. + public static bool operator ==(MatchedBlockName left, MatchedBlockName right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MatchedBlockName left, MatchedBlockName right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MatchedBlockName(string value) => new MatchedBlockName(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MatchedBlockName other && Equals(other); + /// + public bool Equals(MatchedBlockName other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/OnFailure.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/OnFailure.cs new file mode 100644 index 000000000000..b62679b2a80b --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/OnFailure.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Action to be taken when the operation fails for a object. + public readonly partial struct OnFailure : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OnFailure(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string BreakValue = "break"; + + /// break. + public static OnFailure Break { get; } = new OnFailure(BreakValue); + /// Determines if two values are the same. + public static bool operator ==(OnFailure left, OnFailure right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OnFailure left, OnFailure right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OnFailure(string value) => new OnFailure(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OnFailure other && Equals(other); + /// + public bool Equals(OnFailure other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/OnSuccess.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/OnSuccess.cs new file mode 100644 index 000000000000..4aa80d87daa4 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/OnSuccess.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Action to be taken when the operation is successful for a object. + public readonly partial struct OnSuccess : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OnSuccess(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ContinueValue = "continue"; + + /// continue. + public static OnSuccess Continue { get; } = new OnSuccess(ContinueValue); + /// Determines if two values are the same. + public static bool operator ==(OnSuccess left, OnSuccess right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OnSuccess left, OnSuccess right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OnSuccess(string value) => new OnSuccess(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OnSuccess other && Equals(other); + /// + public bool Equals(OnSuccess other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ProvisioningState.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ProvisioningState.Serialization.cs new file mode 100644 index 000000000000..b6b29c68d2e7 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ProvisioningState.Serialization.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Storageactions.Models +{ + internal static partial class ProvisioningStateExtensions + { + public static string ToSerialString(this ProvisioningState value) => value switch + { + ProvisioningState.ValidateSubscriptionQuotaBegin => "ValidateSubscriptionQuotaBegin", + ProvisioningState.ValidateSubscriptionQuotaEnd => "ValidateSubscriptionQuotaEnd", + ProvisioningState.Creating => "Creating", + ProvisioningState.Succeeded => "Succeeded", + ProvisioningState.Deleting => "Deleting", + ProvisioningState.Canceled => "Canceled", + ProvisioningState.Failed => "Failed", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ProvisioningState value.") + }; + + public static ProvisioningState ToProvisioningState(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateSubscriptionQuotaBegin")) return ProvisioningState.ValidateSubscriptionQuotaBegin; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateSubscriptionQuotaEnd")) return ProvisioningState.ValidateSubscriptionQuotaEnd; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Creating")) return ProvisioningState.Creating; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Succeeded")) return ProvisioningState.Succeeded; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Deleting")) return ProvisioningState.Deleting; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Canceled")) return ProvisioningState.Canceled; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Failed")) return ProvisioningState.Failed; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ProvisioningState value."); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ProvisioningState.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..3fc7f370a4fe --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Represents the provisioning state of the storage task. + public enum ProvisioningState + { + /// ValidateSubscriptionQuotaBegin. + ValidateSubscriptionQuotaBegin, + /// ValidateSubscriptionQuotaEnd. + ValidateSubscriptionQuotaEnd, + /// Creating. + Creating, + /// Succeeded. + Succeeded, + /// Deleting. + Deleting, + /// Canceled. + Canceled, + /// Failed. + Failed + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/RunResult.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/RunResult.cs new file mode 100644 index 000000000000..20ddc7ea5afa --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/RunResult.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Represents the overall result of the execution for the run instance. + public readonly partial struct RunResult : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunResult(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + + /// Succeeded. + public static RunResult Succeeded { get; } = new RunResult(SucceededValue); + /// Failed. + public static RunResult Failed { get; } = new RunResult(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(RunResult left, RunResult right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunResult left, RunResult right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator RunResult(string value) => new RunResult(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunResult other && Equals(other); + /// + public bool Equals(RunResult other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/RunStatusEnum.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/RunStatusEnum.cs new file mode 100644 index 000000000000..4a9fa8c320ed --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/RunStatusEnum.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Represents the status of the execution. + public readonly partial struct RunStatusEnum : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStatusEnum(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "InProgress"; + private const string FinishedValue = "Finished"; + + /// InProgress. + public static RunStatusEnum InProgress { get; } = new RunStatusEnum(InProgressValue); + /// Finished. + public static RunStatusEnum Finished { get; } = new RunStatusEnum(FinishedValue); + /// Determines if two values are the same. + public static bool operator ==(RunStatusEnum left, RunStatusEnum right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStatusEnum left, RunStatusEnum right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator RunStatusEnum(string value) => new RunStatusEnum(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStatusEnum other && Equals(other); + /// + public bool Equals(RunStatusEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAction.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAction.Serialization.cs new file mode 100644 index 000000000000..4a7d489428b8 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAction.Serialization.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class StorageTaskAction : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("if"u8); + writer.WriteObjectValue(If); + if (Optional.IsDefined(Else)) + { + writer.WritePropertyName("else"u8); + writer.WriteObjectValue(Else); + } + writer.WriteEndObject(); + } + + internal static StorageTaskAction DeserializeStorageTaskAction(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IfCondition @if = default; + Optional @else = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("if"u8)) + { + @if = IfCondition.DeserializeIfCondition(property.Value); + continue; + } + if (property.NameEquals("else"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @else = ElseCondition.DeserializeElseCondition(property.Value); + continue; + } + } + return new StorageTaskAction(@if, @else.Value); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAction.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAction.cs new file mode 100644 index 000000000000..f8845a598fc1 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAction.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// The storage task action represents conditional statements and operations to be performed on target objects. + public partial class StorageTaskAction + { + /// Initializes a new instance of StorageTaskAction. + /// The if block of storage task operation. + /// is null. + public StorageTaskAction(IfCondition @if) + { + Argument.AssertNotNull(@if, nameof(@if)); + + If = @if; + } + + /// Initializes a new instance of StorageTaskAction. + /// The if block of storage task operation. + /// The else block of storage task operation. + internal StorageTaskAction(IfCondition @if, ElseCondition @else) + { + If = @if; + Else = @else; + } + + /// The if block of storage task operation. + public IfCondition If { get; set; } + /// The else block of storage task operation. + internal ElseCondition Else { get; set; } + /// List of operations to execute in the else block. + public IList ElseOperations + { + get => Else is null ? default : Else.Operations; + set => Else = new ElseCondition(value); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAssignmentsListResult.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAssignmentsListResult.Serialization.cs new file mode 100644 index 000000000000..dff7c84e3e74 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAssignmentsListResult.Serialization.cs @@ -0,0 +1,50 @@ +// 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.Resources.Models; + +namespace Azure.ResourceManager.Storageactions.Models +{ + internal partial class StorageTaskAssignmentsListResult + { + internal static StorageTaskAssignmentsListResult DeserializeStorageTaskAssignmentsListResult(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(JsonSerializer.Deserialize(item.GetRawText())); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new StorageTaskAssignmentsListResult(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAssignmentsListResult.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAssignmentsListResult.cs new file mode 100644 index 000000000000..300a970c1296 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskAssignmentsListResult.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.Resources.Models; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// The response from the List Storage Tasks operation. + internal partial class StorageTaskAssignmentsListResult + { + /// Initializes a new instance of StorageTaskAssignmentsListResult. + internal StorageTaskAssignmentsListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of StorageTaskAssignmentsListResult. + /// Gets the list of storage task assignment Ids. + /// Request URL that can be used to query next page of storage task assignment Ids. Returned when total number of requested storage task assignment Ids exceed maximum page size. + internal StorageTaskAssignmentsListResult(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// Gets the list of storage task assignment Ids. + public IReadOnlyList Value { get; } + /// Request URL that can be used to query next page of storage task assignment Ids. Returned when total number of requested storage task assignment Ids exceed maximum page size. + public string NextLink { get; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskData.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskData.Serialization.cs new file mode 100644 index 000000000000..66a905de8afd --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskData.Serialization.cs @@ -0,0 +1,202 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Storageactions.Models; + +namespace Azure.ResourceManager.Storageactions +{ + public partial class StorageTaskData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + JsonSerializer.Serialize(writer, Identity, serializeOptions); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Action)) + { + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static StorageTaskData DeserializeStorageTaskData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional identity = default; + Optional> tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional taskVersion = default; + Optional enabled = default; + Optional description = default; + Optional action = default; + Optional provisioningState = default; + Optional creationTimeInUtc = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("taskVersion"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + taskVersion = property0.Value.GetInt64(); + continue; + } + if (property0.NameEquals("enabled"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enabled = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("description"u8)) + { + description = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("action"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + action = StorageTaskAction.DeserializeStorageTaskAction(property0.Value); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = property0.Value.GetString().ToProvisioningState(); + continue; + } + if (property0.NameEquals("creationTimeInUtc"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + creationTimeInUtc = property0.Value.GetDateTimeOffset("O"); + continue; + } + } + continue; + } + } + return new StorageTaskData(id, name, type, systemData.Value, Optional.ToDictionary(tags), location, identity, Optional.ToNullable(taskVersion), Optional.ToNullable(enabled), description.Value, action.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(creationTimeInUtc)); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskOperation.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskOperation.Serialization.cs new file mode 100644 index 000000000000..838c33c11e8a --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskOperation.Serialization.cs @@ -0,0 +1,98 @@ +// 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; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class StorageTaskOperation : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name.ToString()); + if (Optional.IsCollectionDefined(Parameters)) + { + writer.WritePropertyName("parameters"u8); + writer.WriteStartObject(); + foreach (var item in Parameters) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(OnSuccess)) + { + writer.WritePropertyName("onSuccess"u8); + writer.WriteStringValue(OnSuccess.Value.ToString()); + } + if (Optional.IsDefined(OnFailure)) + { + writer.WritePropertyName("onFailure"u8); + writer.WriteStringValue(OnFailure.Value.ToString()); + } + writer.WriteEndObject(); + } + + internal static StorageTaskOperation DeserializeStorageTaskOperation(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StorageTaskOperationName name = default; + Optional> parameters = default; + Optional onSuccess = default; + Optional onFailure = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = new StorageTaskOperationName(property.Value.GetString()); + continue; + } + if (property.NameEquals("parameters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + parameters = dictionary; + continue; + } + if (property.NameEquals("onSuccess"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + onSuccess = new OnSuccess(property.Value.GetString()); + continue; + } + if (property.NameEquals("onFailure"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + onFailure = new OnFailure(property.Value.GetString()); + continue; + } + } + return new StorageTaskOperation(name, Optional.ToDictionary(parameters), Optional.ToNullable(onSuccess), Optional.ToNullable(onFailure)); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskOperation.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskOperation.cs new file mode 100644 index 000000000000..5ab53c470dd7 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskOperation.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Represents an operation to be performed on the object. + public partial class StorageTaskOperation + { + /// Initializes a new instance of StorageTaskOperation. + /// The operation to be performed on the object. + public StorageTaskOperation(StorageTaskOperationName name) + { + Name = name; + Parameters = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of StorageTaskOperation. + /// The operation to be performed on the object. + /// Key-value parameters for the operation. + /// Action to be taken when the operation is successful for a object. + /// Action to be taken when the operation fails for a object. + internal StorageTaskOperation(StorageTaskOperationName name, IDictionary parameters, OnSuccess? onSuccess, OnFailure? onFailure) + { + Name = name; + Parameters = parameters; + OnSuccess = onSuccess; + OnFailure = onFailure; + } + + /// The operation to be performed on the object. + public StorageTaskOperationName Name { get; set; } + /// Key-value parameters for the operation. + public IDictionary Parameters { get; } + /// Action to be taken when the operation is successful for a object. + public OnSuccess? OnSuccess { get; set; } + /// Action to be taken when the operation fails for a object. + public OnFailure? OnFailure { get; set; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskOperationName.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskOperationName.cs new file mode 100644 index 000000000000..d89cb7ad6c85 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskOperationName.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// The operation to be performed on the object. + public readonly partial struct StorageTaskOperationName : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public StorageTaskOperationName(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SetBlobTierValue = "SetBlobTier"; + private const string SetBlobTagsValue = "SetBlobTags"; + private const string SetBlobImmutabilityPolicyValue = "SetBlobImmutabilityPolicy"; + private const string SetBlobLegalHoldValue = "SetBlobLegalHold"; + private const string SetBlobExpiryValue = "SetBlobExpiry"; + private const string DeleteBlobValue = "DeleteBlob"; + private const string UndeleteBlobValue = "UndeleteBlob"; + + /// SetBlobTier. + public static StorageTaskOperationName SetBlobTier { get; } = new StorageTaskOperationName(SetBlobTierValue); + /// SetBlobTags. + public static StorageTaskOperationName SetBlobTags { get; } = new StorageTaskOperationName(SetBlobTagsValue); + /// SetBlobImmutabilityPolicy. + public static StorageTaskOperationName SetBlobImmutabilityPolicy { get; } = new StorageTaskOperationName(SetBlobImmutabilityPolicyValue); + /// SetBlobLegalHold. + public static StorageTaskOperationName SetBlobLegalHold { get; } = new StorageTaskOperationName(SetBlobLegalHoldValue); + /// SetBlobExpiry. + public static StorageTaskOperationName SetBlobExpiry { get; } = new StorageTaskOperationName(SetBlobExpiryValue); + /// DeleteBlob. + public static StorageTaskOperationName DeleteBlob { get; } = new StorageTaskOperationName(DeleteBlobValue); + /// UndeleteBlob. + public static StorageTaskOperationName UndeleteBlob { get; } = new StorageTaskOperationName(UndeleteBlobValue); + /// Determines if two values are the same. + public static bool operator ==(StorageTaskOperationName left, StorageTaskOperationName right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(StorageTaskOperationName left, StorageTaskOperationName right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator StorageTaskOperationName(string value) => new StorageTaskOperationName(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is StorageTaskOperationName other && Equals(other); + /// + public bool Equals(StorageTaskOperationName other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPatch.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPatch.Serialization.cs new file mode 100644 index 000000000000..aedea354fcfc --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPatch.Serialization.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class StorageTaskPatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + JsonSerializer.Serialize(writer, Identity, serializeOptions); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Action)) + { + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPatch.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPatch.cs new file mode 100644 index 000000000000..721936e66246 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPatch.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Parameters of the storage task update request. + public partial class StorageTaskPatch + { + /// Initializes a new instance of StorageTaskPatch. + public StorageTaskPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// The identity of the resource. + public ManagedServiceIdentity Identity { get; set; } + /// Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in length than 128 characters and a value no greater in length than 256 characters. + public IDictionary Tags { get; } + /// Storage task version. + public long? TaskVersion { get; } + /// Storage Task is enabled when set to true and disabled when set to false. + public bool? Enabled { get; set; } + /// Text that describes the purpose of the storage task. + public string Description { get; set; } + /// The storage task action that is executed. + public StorageTaskAction Action { get; set; } + /// Represents the provisioning state of the storage task. + public ProvisioningState? ProvisioningState { get; } + /// The creation date and time of the storage task in UTC. + public DateTimeOffset? CreationTimeInUtc { get; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewAction.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewAction.Serialization.cs new file mode 100644 index 000000000000..a3bda387a9c5 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewAction.Serialization.cs @@ -0,0 +1,83 @@ +// 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; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class StorageTaskPreviewAction : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + writer.WritePropertyName("container"u8); + writer.WriteObjectValue(Container); + writer.WritePropertyName("blobs"u8); + writer.WriteStartArray(); + foreach (var item in Blobs) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action); + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static StorageTaskPreviewAction DeserializeStorageTaskPreviewAction(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StorageTaskPreviewContainerProperties container = default; + IList blobs = default; + StorageTaskPreviewActionCondition action = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("container"u8)) + { + container = StorageTaskPreviewContainerProperties.DeserializeStorageTaskPreviewContainerProperties(property0.Value); + continue; + } + if (property0.NameEquals("blobs"u8)) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(StorageTaskPreviewBlobProperties.DeserializeStorageTaskPreviewBlobProperties(item)); + } + blobs = array; + continue; + } + if (property0.NameEquals("action"u8)) + { + action = StorageTaskPreviewActionCondition.DeserializeStorageTaskPreviewActionCondition(property0.Value); + continue; + } + } + continue; + } + } + return new StorageTaskPreviewAction(container, blobs, action); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewAction.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewAction.cs new file mode 100644 index 000000000000..59cf35aab33f --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewAction.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Storage Task Preview Action. + public partial class StorageTaskPreviewAction + { + /// Initializes a new instance of StorageTaskPreviewAction. + /// Preview action container properties to be tested for a match with the provided condition. + /// Preview action container properties to be tested for a match with the provided condition. + /// Preview action container properties to be tested for a match with the provided condition. + /// , or is null. + public StorageTaskPreviewAction(StorageTaskPreviewContainerProperties container, IEnumerable blobs, StorageTaskPreviewActionCondition action) + { + Argument.AssertNotNull(container, nameof(container)); + Argument.AssertNotNull(blobs, nameof(blobs)); + Argument.AssertNotNull(action, nameof(action)); + + Container = container; + Blobs = blobs.ToList(); + Action = action; + } + + /// Initializes a new instance of StorageTaskPreviewAction. + /// Preview action container properties to be tested for a match with the provided condition. + /// Preview action container properties to be tested for a match with the provided condition. + /// Preview action container properties to be tested for a match with the provided condition. + internal StorageTaskPreviewAction(StorageTaskPreviewContainerProperties container, IList blobs, StorageTaskPreviewActionCondition action) + { + Container = container; + Blobs = blobs; + Action = action; + } + + /// Preview action container properties to be tested for a match with the provided condition. + public StorageTaskPreviewContainerProperties Container { get; set; } + /// Preview action container properties to be tested for a match with the provided condition. + public IList Blobs { get; } + /// Preview action container properties to be tested for a match with the provided condition. + public StorageTaskPreviewActionCondition Action { get; set; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionCondition.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionCondition.Serialization.cs new file mode 100644 index 000000000000..3d09c816a680 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionCondition.Serialization.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class StorageTaskPreviewActionCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("if"u8); + writer.WriteObjectValue(If); + writer.WritePropertyName("elseBlockExists"u8); + writer.WriteBooleanValue(ElseBlockExists); + writer.WriteEndObject(); + } + + internal static StorageTaskPreviewActionCondition DeserializeStorageTaskPreviewActionCondition(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StorageTaskPreviewActionIfCondition @if = default; + bool elseBlockExists = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("if"u8)) + { + @if = StorageTaskPreviewActionIfCondition.DeserializeStorageTaskPreviewActionIfCondition(property.Value); + continue; + } + if (property.NameEquals("elseBlockExists"u8)) + { + elseBlockExists = property.Value.GetBoolean(); + continue; + } + } + return new StorageTaskPreviewActionCondition(@if, elseBlockExists); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionCondition.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionCondition.cs new file mode 100644 index 000000000000..d4dac4de819b --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionCondition.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Represents the storage task conditions to be tested for a match with container and blob properties. + public partial class StorageTaskPreviewActionCondition + { + /// Initializes a new instance of StorageTaskPreviewActionCondition. + /// The condition to be tested for a match with container and blob properties. + /// Specify whether the else block is present in the condition. + /// is null. + public StorageTaskPreviewActionCondition(StorageTaskPreviewActionIfCondition @if, bool elseBlockExists) + { + Argument.AssertNotNull(@if, nameof(@if)); + + If = @if; + ElseBlockExists = elseBlockExists; + } + + /// The condition to be tested for a match with container and blob properties. + internal StorageTaskPreviewActionIfCondition If { get; set; } + /// Storage task condition to bes tested for a match. + public string IfCondition + { + get => If is null ? default : If.Condition; + set + { + if (If is null) + If = new StorageTaskPreviewActionIfCondition(); + If.Condition = value; + } + } + + /// Specify whether the else block is present in the condition. + public bool ElseBlockExists { get; set; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionIfCondition.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionIfCondition.Serialization.cs new file mode 100644 index 000000000000..663b08cabace --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionIfCondition.Serialization.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class StorageTaskPreviewActionIfCondition : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Condition)) + { + writer.WritePropertyName("condition"u8); + writer.WriteStringValue(Condition); + } + writer.WriteEndObject(); + } + + internal static StorageTaskPreviewActionIfCondition DeserializeStorageTaskPreviewActionIfCondition(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional condition = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("condition"u8)) + { + condition = property.Value.GetString(); + continue; + } + } + return new StorageTaskPreviewActionIfCondition(condition.Value); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionIfCondition.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionIfCondition.cs new file mode 100644 index 000000000000..e10945cf6a85 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewActionIfCondition.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Represents storage task preview action condition. + public partial class StorageTaskPreviewActionIfCondition + { + /// Initializes a new instance of StorageTaskPreviewActionIfCondition. + public StorageTaskPreviewActionIfCondition() + { + } + + /// Initializes a new instance of StorageTaskPreviewActionIfCondition. + /// Storage task condition to bes tested for a match. + internal StorageTaskPreviewActionIfCondition(string condition) + { + Condition = condition; + } + + /// Storage task condition to bes tested for a match. + public string Condition { get; set; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewBlobProperties.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewBlobProperties.Serialization.cs new file mode 100644 index 000000000000..62ff38990890 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewBlobProperties.Serialization.cs @@ -0,0 +1,130 @@ +// 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; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class StorageTaskPreviewBlobProperties : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartArray(); + foreach (var item in Properties) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartArray(); + foreach (var item in Metadata) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartArray(); + foreach (var item in Tags) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + internal static StorageTaskPreviewBlobProperties DeserializeStorageTaskPreviewBlobProperties(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional name = default; + Optional> properties = default; + Optional> metadata = default; + Optional> tags = default; + Optional matchedBlock = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StorageTaskPreviewKeyValueProperties.DeserializeStorageTaskPreviewKeyValueProperties(item)); + } + properties = array; + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StorageTaskPreviewKeyValueProperties.DeserializeStorageTaskPreviewKeyValueProperties(item)); + } + metadata = array; + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StorageTaskPreviewKeyValueProperties.DeserializeStorageTaskPreviewKeyValueProperties(item)); + } + tags = array; + continue; + } + if (property.NameEquals("matchedBlock"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + matchedBlock = new MatchedBlockName(property.Value.GetString()); + continue; + } + } + return new StorageTaskPreviewBlobProperties(name.Value, Optional.ToList(properties), Optional.ToList(metadata), Optional.ToList(tags), Optional.ToNullable(matchedBlock)); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewBlobProperties.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewBlobProperties.cs new file mode 100644 index 000000000000..d72982d0ab90 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewBlobProperties.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Storage task preview container properties. + public partial class StorageTaskPreviewBlobProperties + { + /// Initializes a new instance of StorageTaskPreviewBlobProperties. + public StorageTaskPreviewBlobProperties() + { + Properties = new ChangeTrackingList(); + Metadata = new ChangeTrackingList(); + Tags = new ChangeTrackingList(); + } + + /// Initializes a new instance of StorageTaskPreviewBlobProperties. + /// property for the container name. + /// properties key value pairs to be tested for a match against the provided condition. + /// metadata key value pairs to be tested for a match against the provided condition. + /// tags key value pairs to be tested for a match against the provided condition. + /// Represents the condition block name that matched blob properties. + internal StorageTaskPreviewBlobProperties(string name, IList properties, IList metadata, IList tags, MatchedBlockName? matchedBlock) + { + Name = name; + Properties = properties; + Metadata = metadata; + Tags = tags; + MatchedBlock = matchedBlock; + } + + /// property for the container name. + public string Name { get; set; } + /// properties key value pairs to be tested for a match against the provided condition. + public IList Properties { get; } + /// metadata key value pairs to be tested for a match against the provided condition. + public IList Metadata { get; } + /// tags key value pairs to be tested for a match against the provided condition. + public IList Tags { get; } + /// Represents the condition block name that matched blob properties. + public MatchedBlockName? MatchedBlock { get; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewContainerProperties.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewContainerProperties.Serialization.cs new file mode 100644 index 000000000000..dbf93a1beab4 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewContainerProperties.Serialization.cs @@ -0,0 +1,70 @@ +// 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; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class StorageTaskPreviewContainerProperties : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartArray(); + foreach (var item in Metadata) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + internal static StorageTaskPreviewContainerProperties DeserializeStorageTaskPreviewContainerProperties(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional name = default; + Optional> metadata = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StorageTaskPreviewKeyValueProperties.DeserializeStorageTaskPreviewKeyValueProperties(item)); + } + metadata = array; + continue; + } + } + return new StorageTaskPreviewContainerProperties(name.Value, Optional.ToList(metadata)); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewContainerProperties.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewContainerProperties.cs new file mode 100644 index 000000000000..9da8de72ee92 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewContainerProperties.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Storage task preview container properties. + public partial class StorageTaskPreviewContainerProperties + { + /// Initializes a new instance of StorageTaskPreviewContainerProperties. + public StorageTaskPreviewContainerProperties() + { + Metadata = new ChangeTrackingList(); + } + + /// Initializes a new instance of StorageTaskPreviewContainerProperties. + /// property for the container name. + /// metadata key value pairs to be tested for a match against the provided condition. + internal StorageTaskPreviewContainerProperties(string name, IList metadata) + { + Name = name; + Metadata = metadata; + } + + /// property for the container name. + public string Name { get; set; } + /// metadata key value pairs to be tested for a match against the provided condition. + public IList Metadata { get; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewKeyValueProperties.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewKeyValueProperties.Serialization.cs new file mode 100644 index 000000000000..027a71190dc1 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewKeyValueProperties.Serialization.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class StorageTaskPreviewKeyValueProperties : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Key)) + { + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + } + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + writer.WriteEndObject(); + } + + internal static StorageTaskPreviewKeyValueProperties DeserializeStorageTaskPreviewKeyValueProperties(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional key = default; + Optional value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("key"u8)) + { + key = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + } + return new StorageTaskPreviewKeyValueProperties(key.Value, value.Value); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewKeyValueProperties.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewKeyValueProperties.cs new file mode 100644 index 000000000000..58e94fc5f414 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskPreviewKeyValueProperties.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Storage task preview object key value pair properties. + public partial class StorageTaskPreviewKeyValueProperties + { + /// Initializes a new instance of StorageTaskPreviewKeyValueProperties. + public StorageTaskPreviewKeyValueProperties() + { + } + + /// Initializes a new instance of StorageTaskPreviewKeyValueProperties. + /// Represents the key property of the pair. + /// Represents the value property of the pair. + internal StorageTaskPreviewKeyValueProperties(string key, string value) + { + Key = key; + Value = value; + } + + /// Represents the key property of the pair. + public string Key { get; set; } + /// Represents the value property of the pair. + public string Value { get; set; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportInstance.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportInstance.Serialization.cs new file mode 100644 index 000000000000..b272411d9aa1 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportInstance.Serialization.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class StorageTaskReportInstance : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties); + } + writer.WriteEndObject(); + } + + internal static StorageTaskReportInstance DeserializeStorageTaskReportInstance(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = StorageTaskReportProperties.DeserializeStorageTaskReportProperties(property.Value); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + } + return new StorageTaskReportInstance(id, name, type, systemData.Value, properties.Value); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportInstance.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportInstance.cs new file mode 100644 index 000000000000..5ec2e35b02fb --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportInstance.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Storage Tasks run report instance. + public partial class StorageTaskReportInstance : ResourceData + { + /// Initializes a new instance of StorageTaskReportInstance. + public StorageTaskReportInstance() + { + } + + /// Initializes a new instance of StorageTaskReportInstance. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Storage task execution report for a run instance. + internal StorageTaskReportInstance(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, StorageTaskReportProperties properties) : base(id, name, resourceType, systemData) + { + Properties = properties; + } + + /// Storage task execution report for a run instance. + public StorageTaskReportProperties Properties { get; set; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportProperties.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportProperties.Serialization.cs new file mode 100644 index 000000000000..d2ebdf873796 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportProperties.Serialization.cs @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + public partial class StorageTaskReportProperties : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } + + internal static StorageTaskReportProperties DeserializeStorageTaskReportProperties(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional taskAssignmentId = default; + Optional storageAccountId = default; + Optional startTime = default; + Optional finishTime = default; + Optional objectsTargetedCount = default; + Optional objectsOperatedOnCount = default; + Optional objectFailedCount = default; + Optional objectsSucceededCount = default; + Optional runStatusError = default; + Optional runStatusEnum = default; + Optional summaryReportPath = default; + Optional taskId = default; + Optional taskVersion = default; + Optional runResult = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("taskAssignmentId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + taskAssignmentId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("storageAccountId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + storageAccountId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("startTime"u8)) + { + startTime = property.Value.GetString(); + continue; + } + if (property.NameEquals("finishTime"u8)) + { + finishTime = property.Value.GetString(); + continue; + } + if (property.NameEquals("objectsTargetedCount"u8)) + { + objectsTargetedCount = property.Value.GetString(); + continue; + } + if (property.NameEquals("objectsOperatedOnCount"u8)) + { + objectsOperatedOnCount = property.Value.GetString(); + continue; + } + if (property.NameEquals("objectFailedCount"u8)) + { + objectFailedCount = property.Value.GetString(); + continue; + } + if (property.NameEquals("objectsSucceededCount"u8)) + { + objectsSucceededCount = property.Value.GetString(); + continue; + } + if (property.NameEquals("runStatusError"u8)) + { + runStatusError = property.Value.GetString(); + continue; + } + if (property.NameEquals("runStatusEnum"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + runStatusEnum = new RunStatusEnum(property.Value.GetString()); + continue; + } + if (property.NameEquals("summaryReportPath"u8)) + { + summaryReportPath = property.Value.GetString(); + continue; + } + if (property.NameEquals("taskId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + taskId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("taskVersion"u8)) + { + taskVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("runResult"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + runResult = new RunResult(property.Value.GetString()); + continue; + } + } + return new StorageTaskReportProperties(taskAssignmentId.Value, storageAccountId.Value, startTime.Value, finishTime.Value, objectsTargetedCount.Value, objectsOperatedOnCount.Value, objectFailedCount.Value, objectsSucceededCount.Value, runStatusError.Value, Optional.ToNullable(runStatusEnum), summaryReportPath.Value, taskId.Value, taskVersion.Value, Optional.ToNullable(runResult)); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportProperties.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportProperties.cs new file mode 100644 index 000000000000..9b1a3dc88da2 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportProperties.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Storage task execution report for a run instance. + public partial class StorageTaskReportProperties + { + /// Initializes a new instance of StorageTaskReportProperties. + public StorageTaskReportProperties() + { + } + + /// Initializes a new instance of StorageTaskReportProperties. + /// Represents the Storage Task Assignment Id associated with the storage task that provided an execution context. + /// Represents the Storage Account Id where the storage task definition was applied and executed. + /// Start time of the run instance. Filter options such as startTime gt '2023-06-26T20:51:24.4494016Z' and other comparison operators can be used as described for DateTime properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// End time of the run instance. Filter options such as startTime gt '2023-06-26T20:51:24.4494016Z' and other comparison operators can be used as described for DateTime properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// Total number of objects that meet the condition as defined in the storage task assignment execution context. Filter options such as objectsTargetedCount gt 50 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// Total number of objects that meet the storage tasks condition and were operated upon. Filter options such as objectsOperatedOnCount ge 100 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// Total number of objects where task operation failed when was attempted. Filter options such as objectFailedCount eq 0 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// Total number of objects where task operation succeeded when was attempted.Filter options such as objectsSucceededCount gt 150 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + /// Well known Azure Storage error code that represents the error encountered during execution of the run instance. + /// Represents the status of the execution. + /// Full path to the verbose report stored in the reporting container as specified in the assignment execution context for the storage account. + /// Storage Task Arm Id. + /// Storage Task Version. + /// Represents the overall result of the execution for the run instance. + internal StorageTaskReportProperties(ResourceIdentifier taskAssignmentId, ResourceIdentifier storageAccountId, string startTime, string finishTime, string objectsTargetedCount, string objectsOperatedOnCount, string objectFailedCount, string objectsSucceededCount, string runStatusError, RunStatusEnum? runStatusEnum, string summaryReportPath, ResourceIdentifier taskId, string taskVersion, RunResult? runResult) + { + TaskAssignmentId = taskAssignmentId; + StorageAccountId = storageAccountId; + StartTime = startTime; + FinishTime = finishTime; + ObjectsTargetedCount = objectsTargetedCount; + ObjectsOperatedOnCount = objectsOperatedOnCount; + ObjectFailedCount = objectFailedCount; + ObjectsSucceededCount = objectsSucceededCount; + RunStatusError = runStatusError; + RunStatusEnum = runStatusEnum; + SummaryReportPath = summaryReportPath; + TaskId = taskId; + TaskVersion = taskVersion; + RunResult = runResult; + } + + /// Represents the Storage Task Assignment Id associated with the storage task that provided an execution context. + public ResourceIdentifier TaskAssignmentId { get; } + /// Represents the Storage Account Id where the storage task definition was applied and executed. + public ResourceIdentifier StorageAccountId { get; } + /// Start time of the run instance. Filter options such as startTime gt '2023-06-26T20:51:24.4494016Z' and other comparison operators can be used as described for DateTime properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + public string StartTime { get; } + /// End time of the run instance. Filter options such as startTime gt '2023-06-26T20:51:24.4494016Z' and other comparison operators can be used as described for DateTime properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + public string FinishTime { get; } + /// Total number of objects that meet the condition as defined in the storage task assignment execution context. Filter options such as objectsTargetedCount gt 50 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + public string ObjectsTargetedCount { get; } + /// Total number of objects that meet the storage tasks condition and were operated upon. Filter options such as objectsOperatedOnCount ge 100 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + public string ObjectsOperatedOnCount { get; } + /// Total number of objects where task operation failed when was attempted. Filter options such as objectFailedCount eq 0 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + public string ObjectFailedCount { get; } + /// Total number of objects where task operation succeeded when was attempted.Filter options such as objectsSucceededCount gt 150 and other comparison operators can be used as described for Numerical properties in https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. + public string ObjectsSucceededCount { get; } + /// Well known Azure Storage error code that represents the error encountered during execution of the run instance. + public string RunStatusError { get; } + /// Represents the status of the execution. + public RunStatusEnum? RunStatusEnum { get; } + /// Full path to the verbose report stored in the reporting container as specified in the assignment execution context for the storage account. + public string SummaryReportPath { get; } + /// Storage Task Arm Id. + public ResourceIdentifier TaskId { get; } + /// Storage Task Version. + public string TaskVersion { get; } + /// Represents the overall result of the execution for the run instance. + public RunResult? RunResult { get; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportSummary.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportSummary.Serialization.cs new file mode 100644 index 000000000000..1f820ac5d1a0 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportSummary.Serialization.cs @@ -0,0 +1,49 @@ +// 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; + +namespace Azure.ResourceManager.Storageactions.Models +{ + internal partial class StorageTaskReportSummary + { + internal static StorageTaskReportSummary DeserializeStorageTaskReportSummary(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StorageTaskReportInstance.DeserializeStorageTaskReportInstance(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new StorageTaskReportSummary(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportSummary.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportSummary.cs new file mode 100644 index 000000000000..a08fd0026bb6 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTaskReportSummary.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// Fetch Storage Tasks Run Summary. + internal partial class StorageTaskReportSummary + { + /// Initializes a new instance of StorageTaskReportSummary. + internal StorageTaskReportSummary() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of StorageTaskReportSummary. + /// Gets storage tasks run result summary. + /// Request URL that can be used to query next page of storage task run results summary. Returned when the number of run instances and summary reports exceed maximum page size. + internal StorageTaskReportSummary(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// Gets storage tasks run result summary. + public IReadOnlyList Value { get; } + /// Request URL that can be used to query next page of storage task run results summary. Returned when the number of run instances and summary reports exceed maximum page size. + public string NextLink { get; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTasksListResult.Serialization.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTasksListResult.Serialization.cs new file mode 100644 index 000000000000..ff2beeab67ac --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTasksListResult.Serialization.cs @@ -0,0 +1,50 @@ +// 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.Storageactions; + +namespace Azure.ResourceManager.Storageactions.Models +{ + internal partial class StorageTasksListResult + { + internal static StorageTasksListResult DeserializeStorageTasksListResult(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StorageTaskData.DeserializeStorageTaskData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new StorageTasksListResult(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTasksListResult.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTasksListResult.cs new file mode 100644 index 000000000000..36a8ecc5e5d4 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/Models/StorageTasksListResult.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.Storageactions; + +namespace Azure.ResourceManager.Storageactions.Models +{ + /// The response from the List Storage Tasks operation. + internal partial class StorageTasksListResult + { + /// Initializes a new instance of StorageTasksListResult. + internal StorageTasksListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of StorageTasksListResult. + /// Gets the list of storage tasks and their properties. + /// Request URL that can be used to query next page of storage tasks. Returned when total number of requested storage tasks exceed maximum page size. + internal StorageTasksListResult(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// Gets the list of storage tasks and their properties. + public IReadOnlyList Value { get; } + /// Request URL that can be used to query next page of storage tasks. Returned when total number of requested storage tasks exceed maximum page size. + public string NextLink { get; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/ProviderConstants.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..102bb59da150 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/ProviderConstants.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Storageactions +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/RestOperations/StorageTaskAssignmentRestOperations.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/RestOperations/StorageTaskAssignmentRestOperations.cs new file mode 100644 index 000000000000..264805d1da13 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/RestOperations/StorageTaskAssignmentRestOperations.cs @@ -0,0 +1,203 @@ +// 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.Storageactions.Models; + +namespace Azure.ResourceManager.Storageactions +{ + internal partial class StorageTaskAssignmentRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of StorageTaskAssignmentRestOperations. + /// 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 StorageTaskAssignmentRestOperations(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 ?? "2023-01-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string storageTaskName, string maxpagesize) + { + 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.StorageActions/storageTasks/", false); + uri.AppendPath(storageTaskName, true); + uri.AppendPath("/storageTaskAssignments", false); + if (maxpagesize != null) + { + uri.AppendQuery("$maxpagesize", maxpagesize, true); + } + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists all the storage tasks available under the given resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// 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 storageTaskName, string maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, storageTaskName, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageTaskAssignmentsListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageTaskAssignmentsListResult.DeserializeStorageTaskAssignmentsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all the storage tasks available under the given resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// 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 storageTaskName, string maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, storageTaskName, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageTaskAssignmentsListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageTaskAssignmentsListResult.DeserializeStorageTaskAssignmentsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string storageTaskName, string maxpagesize) + { + 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; + } + + /// Lists all the storage tasks available under the given resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// 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 storageTaskName, string maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, storageTaskName, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageTaskAssignmentsListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageTaskAssignmentsListResult.DeserializeStorageTaskAssignmentsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all the storage tasks available under the given resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// 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 storageTaskName, string maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, storageTaskName, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageTaskAssignmentsListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageTaskAssignmentsListResult.DeserializeStorageTaskAssignmentsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/RestOperations/StorageTasksReportRestOperations.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/RestOperations/StorageTasksReportRestOperations.cs new file mode 100644 index 000000000000..3e64f894dc76 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/RestOperations/StorageTasksReportRestOperations.cs @@ -0,0 +1,211 @@ +// 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.Storageactions.Models; + +namespace Azure.ResourceManager.Storageactions +{ + internal partial class StorageTasksReportRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of StorageTasksReportRestOperations. + /// 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 StorageTasksReportRestOperations(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 ?? "2023-01-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string storageTaskName, string maxpagesize, string filter) + { + 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.StorageActions/storageTasks/", false); + uri.AppendPath(storageTaskName, true); + uri.AppendPath("/reports", false); + if (maxpagesize != null) + { + uri.AppendQuery("$maxpagesize", maxpagesize, true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Fetch the storage tasks run report summary for each assignment. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// Optional. When specified, it can be used to query using reporting properties. + /// 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 storageTaskName, string maxpagesize = null, string filter = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, storageTaskName, maxpagesize, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageTaskReportSummary value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageTaskReportSummary.DeserializeStorageTaskReportSummary(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Fetch the storage tasks run report summary for each assignment. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// Optional. When specified, it can be used to query using reporting properties. + /// 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 storageTaskName, string maxpagesize = null, string filter = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, storageTaskName, maxpagesize, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageTaskReportSummary value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageTaskReportSummary.DeserializeStorageTaskReportSummary(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string storageTaskName, string maxpagesize, string filter) + { + 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; + } + + /// Fetch the storage tasks run report summary for each assignment. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// Optional. When specified, it can be used to query using reporting properties. + /// 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 storageTaskName, string maxpagesize = null, string filter = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, storageTaskName, maxpagesize, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageTaskReportSummary value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageTaskReportSummary.DeserializeStorageTaskReportSummary(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Fetch the storage tasks run report summary for each assignment. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// Optional. When specified, it can be used to query using reporting properties. + /// 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 storageTaskName, string maxpagesize = null, string filter = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, storageTaskName, maxpagesize, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageTaskReportSummary value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageTaskReportSummary.DeserializeStorageTaskReportSummary(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/RestOperations/StorageTasksRestOperations.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/RestOperations/StorageTasksRestOperations.cs new file mode 100644 index 000000000000..9656e37d8670 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/RestOperations/StorageTasksRestOperations.cs @@ -0,0 +1,709 @@ +// 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.Storageactions.Models; + +namespace Azure.ResourceManager.Storageactions +{ + internal partial class StorageTasksRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of StorageTasksRestOperations. + /// 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 StorageTasksRestOperations(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 ?? "2023-01-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string storageTaskName, StorageTaskData data) + { + 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.StorageActions/storageTasks/", false); + uri.AppendPath(storageTaskName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Asynchronously creates a new storage task resource with the specified parameters. If a storage task is already created and a subsequent create request is issued with different properties, the storage task properties will be updated. If a storage task is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The parameters to create a Storage Task. + /// 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 storageTaskName, StorageTaskData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, storageTaskName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Asynchronously creates a new storage task resource with the specified parameters. If a storage task is already created and a subsequent create request is issued with different properties, the storage task properties will be updated. If a storage task is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The parameters to create a Storage Task. + /// 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 storageTaskName, StorageTaskData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, storageTaskName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string storageTaskName) + { + 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.StorageActions/storageTasks/", false); + uri.AppendPath(storageTaskName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete the storage task resource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// 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 storageTaskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, storageTaskName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete the storage task resource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// 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 storageTaskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, storageTaskName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string storageTaskName) + { + 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.StorageActions/storageTasks/", false); + uri.AppendPath(storageTaskName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get the storage task properties. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// 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 storageTaskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, storageTaskName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageTaskData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageTaskData.DeserializeStorageTaskData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((StorageTaskData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get the storage task properties. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// 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 storageTaskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, storageTaskName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageTaskData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageTaskData.DeserializeStorageTaskData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((StorageTaskData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string storageTaskName, StorageTaskPatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + 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.StorageActions/storageTasks/", false); + uri.AppendPath(storageTaskName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update storage task properties. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The parameters to provide to update the storage task resource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string storageTaskName, StorageTaskPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, storageTaskName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update storage task properties. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The parameters to provide to update the storage task resource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string storageTaskName, StorageTaskPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, storageTaskName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId) + { + 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("/providers/Microsoft.StorageActions/storageTasks", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists all the storage tasks available under the subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageTasksListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageTasksListResult.DeserializeStorageTasksListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all the storage tasks available under the subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageTasksListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageTasksListResult.DeserializeStorageTasksListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) + { + 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.StorageActions/storageTasks", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists all the storage tasks available under the given resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageTasksListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageTasksListResult.DeserializeStorageTasksListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all the storage tasks available under the given resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageTasksListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageTasksListResult.DeserializeStorageTasksListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreatePreviewActionsRequest(string subscriptionId, AzureLocation location, StorageTaskPreviewAction storageTaskPreviewAction) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.StorageActions/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/previewActions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(storageTaskPreviewAction); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Runs the input conditions against input object metadata properties and designates matched objects in response. + /// The ID of the target subscription. The value must be an UUID. + /// The location to perform preview of the actions. + /// The parameters to preview action condition. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> PreviewActionsAsync(string subscriptionId, AzureLocation location, StorageTaskPreviewAction storageTaskPreviewAction, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(storageTaskPreviewAction, nameof(storageTaskPreviewAction)); + + using var message = CreatePreviewActionsRequest(subscriptionId, location, storageTaskPreviewAction); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageTaskPreviewAction value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageTaskPreviewAction.DeserializeStorageTaskPreviewAction(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Runs the input conditions against input object metadata properties and designates matched objects in response. + /// The ID of the target subscription. The value must be an UUID. + /// The location to perform preview of the actions. + /// The parameters to preview action condition. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response PreviewActions(string subscriptionId, AzureLocation location, StorageTaskPreviewAction storageTaskPreviewAction, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(storageTaskPreviewAction, nameof(storageTaskPreviewAction)); + + using var message = CreatePreviewActionsRequest(subscriptionId, location, storageTaskPreviewAction); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageTaskPreviewAction value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageTaskPreviewAction.DeserializeStorageTaskPreviewAction(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId) + { + 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; + } + + /// Lists all the storage tasks available under the subscription. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageTasksListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageTasksListResult.DeserializeStorageTasksListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all the storage tasks available under the subscription. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageTasksListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageTasksListResult.DeserializeStorageTasksListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) + { + 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; + } + + /// Lists all the storage tasks available under the given resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageTasksListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageTasksListResult.DeserializeStorageTasksListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all the storage tasks available under the given resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageTasksListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageTasksListResult.DeserializeStorageTasksListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/StorageTaskCollection.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/StorageTaskCollection.cs new file mode 100644 index 000000000000..816432e70a09 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/StorageTaskCollection.cs @@ -0,0 +1,342 @@ +// 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.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Storageactions +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetStorageTasks method from an instance of . + /// + public partial class StorageTaskCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _storageTaskClientDiagnostics; + private readonly StorageTasksRestOperations _storageTaskRestClient; + + /// Initializes a new instance of the class for mocking. + protected StorageTaskCollection() + { + } + + /// 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. + internal StorageTaskCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _storageTaskClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Storageactions", StorageTaskResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(StorageTaskResource.ResourceType, out string storageTaskApiVersion); + _storageTaskRestClient = new StorageTasksRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, storageTaskApiVersion); +#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)); + } + + /// + /// Asynchronously creates a new storage task resource with the specified parameters. If a storage task is already created and a subsequent create request is issued with different properties, the storage task properties will be updated. If a storage task is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_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 name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The parameters to create a Storage Task. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string storageTaskName, StorageTaskData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _storageTaskRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, storageTaskName, data, cancellationToken).ConfigureAwait(false); + var operation = new StorageactionsArmOperation(new StorageTaskOperationSource(Client), _storageTaskClientDiagnostics, Pipeline, _storageTaskRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, storageTaskName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Asynchronously creates a new storage task resource with the specified parameters. If a storage task is already created and a subsequent create request is issued with different properties, the storage task properties will be updated. If a storage task is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_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 name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The parameters to create a Storage Task. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string storageTaskName, StorageTaskData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _storageTaskRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, storageTaskName, data, cancellationToken); + var operation = new StorageactionsArmOperation(new StorageTaskOperationSource(Client), _storageTaskClientDiagnostics, Pipeline, _storageTaskRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, storageTaskName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the storage task properties + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string storageTaskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskCollection.Get"); + scope.Start(); + try + { + var response = await _storageTaskRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, storageTaskName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new StorageTaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the storage task properties + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string storageTaskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskCollection.Get"); + scope.Start(); + try + { + var response = _storageTaskRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, storageTaskName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new StorageTaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all the storage tasks available under the given resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks + /// + /// + /// Operation Id + /// StorageTasks_ListByResourceGroup + /// + /// + /// + /// 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) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _storageTaskRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _storageTaskRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new StorageTaskResource(Client, StorageTaskData.DeserializeStorageTaskData(e)), _storageTaskClientDiagnostics, Pipeline, "StorageTaskCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists all the storage tasks available under the given resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks + /// + /// + /// Operation Id + /// StorageTasks_ListByResourceGroup + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _storageTaskRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _storageTaskRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new StorageTaskResource(Client, StorageTaskData.DeserializeStorageTaskData(e)), _storageTaskClientDiagnostics, Pipeline, "StorageTaskCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string storageTaskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskCollection.Exists"); + scope.Start(); + try + { + var response = await _storageTaskRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, storageTaskName, 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.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string storageTaskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageTaskName, nameof(storageTaskName)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskCollection.Exists"); + scope.Start(); + try + { + var response = _storageTaskRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, storageTaskName, 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/storageactions/Azure.ResourceManager.Storageactions/src/Generated/StorageTaskData.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/StorageTaskData.cs new file mode 100644 index 000000000000..217c49b92506 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/StorageTaskData.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Storageactions.Models; + +namespace Azure.ResourceManager.Storageactions +{ + /// + /// A class representing the StorageTask data model. + /// Represents Storage Task. + /// + public partial class StorageTaskData : TrackedResourceData + { + /// Initializes a new instance of StorageTaskData. + /// The location. + public StorageTaskData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of StorageTaskData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The managed service identity of the resource. + /// Storage task version. + /// Storage Task is enabled when set to true and disabled when set to false. + /// Text that describes the purpose of the storage task. + /// The storage task action that is executed. + /// Represents the provisioning state of the storage task. + /// The creation date and time of the storage task in UTC. + internal StorageTaskData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ManagedServiceIdentity identity, long? taskVersion, bool? enabled, string description, StorageTaskAction action, ProvisioningState? provisioningState, DateTimeOffset? creationTimeInUtc) : base(id, name, resourceType, systemData, tags, location) + { + Identity = identity; + TaskVersion = taskVersion; + Enabled = enabled; + Description = description; + Action = action; + ProvisioningState = provisioningState; + CreationTimeInUtc = creationTimeInUtc; + } + + /// The managed service identity of the resource. + public ManagedServiceIdentity Identity { get; set; } + /// Storage task version. + public long? TaskVersion { get; } + /// Storage Task is enabled when set to true and disabled when set to false. + public bool? Enabled { get; set; } + /// Text that describes the purpose of the storage task. + public string Description { get; set; } + /// The storage task action that is executed. + public StorageTaskAction Action { get; set; } + /// Represents the provisioning state of the storage task. + public ProvisioningState? ProvisioningState { get; } + /// The creation date and time of the storage task in UTC. + public DateTimeOffset? CreationTimeInUtc { get; } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/StorageTaskResource.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/StorageTaskResource.cs new file mode 100644 index 000000000000..49d39d59678c --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Generated/StorageTaskResource.cs @@ -0,0 +1,715 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.Storageactions.Models; + +namespace Azure.ResourceManager.Storageactions +{ + /// + /// A Class representing a StorageTask along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetStorageTaskResource method. + /// Otherwise you can get one from its parent resource using the GetStorageTask method. + /// + public partial class StorageTaskResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string storageTaskName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _storageTaskClientDiagnostics; + private readonly StorageTasksRestOperations _storageTaskRestClient; + private readonly ClientDiagnostics _storageTaskAssignmentClientDiagnostics; + private readonly StorageTaskAssignmentRestOperations _storageTaskAssignmentRestClient; + private readonly ClientDiagnostics _storageTasksReportClientDiagnostics; + private readonly StorageTasksReportRestOperations _storageTasksReportRestClient; + private readonly StorageTaskData _data; + + /// Initializes a new instance of the class for mocking. + protected StorageTaskResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal StorageTaskResource(ArmClient client, StorageTaskData 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 StorageTaskResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _storageTaskClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Storageactions", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string storageTaskApiVersion); + _storageTaskRestClient = new StorageTasksRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, storageTaskApiVersion); + _storageTaskAssignmentClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Storageactions", ProviderConstants.DefaultProviderNamespace, Diagnostics); + _storageTaskAssignmentRestClient = new StorageTaskAssignmentRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + _storageTasksReportClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Storageactions", ProviderConstants.DefaultProviderNamespace, Diagnostics); + _storageTasksReportRestClient = new StorageTasksReportRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.StorageActions/storageTasks"; + + /// 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 StorageTaskData 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)); + } + + /// + /// Get the storage task properties + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.Get"); + scope.Start(); + try + { + var response = await _storageTaskRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new StorageTaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the storage task properties + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.Get"); + scope.Start(); + try + { + var response = _storageTaskRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new StorageTaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete the storage task resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_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 = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.Delete"); + scope.Start(); + try + { + var response = await _storageTaskRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new StorageactionsArmOperation(_storageTaskClientDiagnostics, Pipeline, _storageTaskRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete the storage task resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_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 = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.Delete"); + scope.Start(); + try + { + var response = _storageTaskRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new StorageactionsArmOperation(_storageTaskClientDiagnostics, Pipeline, _storageTaskRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update storage task properties + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Update + /// + /// + /// + /// 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 parameters to provide to update the storage task resource. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, StorageTaskPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.Update"); + scope.Start(); + try + { + var response = await _storageTaskRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new StorageactionsArmOperation(new StorageTaskOperationSource(Client), _storageTaskClientDiagnostics, Pipeline, _storageTaskRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update storage task properties + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Update + /// + /// + /// + /// 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 parameters to provide to update the storage task resource. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, StorageTaskPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.Update"); + scope.Start(); + try + { + var response = _storageTaskRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + var operation = new StorageactionsArmOperation(new StorageTaskOperationSource(Client), _storageTaskClientDiagnostics, Pipeline, _storageTaskRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all the storage tasks available under the given resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName}/storageTaskAssignments + /// + /// + /// Operation Id + /// StorageTaskAssignment_List + /// + /// + /// + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetStorageTaskAssignmentsAsync(string maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _storageTaskAssignmentRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, maxpagesize); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _storageTaskAssignmentRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, maxpagesize); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => JsonSerializer.Deserialize(e.GetRawText()), _storageTaskAssignmentClientDiagnostics, Pipeline, "StorageTaskResource.GetStorageTaskAssignments", "value", "nextLink", cancellationToken); + } + + /// + /// Lists all the storage tasks available under the given resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName}/storageTaskAssignments + /// + /// + /// Operation Id + /// StorageTaskAssignment_List + /// + /// + /// + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetStorageTaskAssignments(string maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _storageTaskAssignmentRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, maxpagesize); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _storageTaskAssignmentRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, maxpagesize); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => JsonSerializer.Deserialize(e.GetRawText()), _storageTaskAssignmentClientDiagnostics, Pipeline, "StorageTaskResource.GetStorageTaskAssignments", "value", "nextLink", cancellationToken); + } + + /// + /// Fetch the storage tasks run report summary for each assignment. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName}/reports + /// + /// + /// Operation Id + /// StorageTasksReport_List + /// + /// + /// + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// Optional. When specified, it can be used to query using reporting properties. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetStorageTasksReportsAsync(string maxpagesize = null, string filter = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _storageTasksReportRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, maxpagesize, filter); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _storageTasksReportRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, maxpagesize, filter); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, StorageTaskReportInstance.DeserializeStorageTaskReportInstance, _storageTasksReportClientDiagnostics, Pipeline, "StorageTaskResource.GetStorageTasksReports", "value", "nextLink", cancellationToken); + } + + /// + /// Fetch the storage tasks run report summary for each assignment. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName}/reports + /// + /// + /// Operation Id + /// StorageTasksReport_List + /// + /// + /// + /// Optional, specifies the maximum number of storage task assignment Ids to be included in the list response. + /// Optional. When specified, it can be used to query using reporting properties. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetStorageTasksReports(string maxpagesize = null, string filter = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _storageTasksReportRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, maxpagesize, filter); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _storageTasksReportRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, maxpagesize, filter); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, StorageTaskReportInstance.DeserializeStorageTaskReportInstance, _storageTasksReportClientDiagnostics, Pipeline, "StorageTaskResource.GetStorageTasksReports", "value", "nextLink", cancellationToken); + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _storageTaskRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new StorageTaskResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new StorageTaskPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _storageTaskRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new StorageTaskResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new StorageTaskPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _storageTaskRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new StorageTaskResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new StorageTaskPatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _storageTaskRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new StorageTaskResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new StorageTaskPatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _storageTaskRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new StorageTaskResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new StorageTaskPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName} + /// + /// + /// Operation Id + /// StorageTasks_Get + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _storageTaskClientDiagnostics.CreateScope("StorageTaskResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _storageTaskRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new StorageTaskResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new StorageTaskPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Properties/AssemblyInfo.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..71a8437bd8d4 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: Azure.Core.AzureResourceProviderNamespace("storageactions")] + +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo("Azure.ResourceManager.Storageactions.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/src/autorest.md b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/autorest.md new file mode 100644 index 000000000000..53e845dcc198 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/src/autorest.md @@ -0,0 +1,55 @@ +# Generated code configuration + +Run `dotnet build /t:GenerateCode` to generate code. + +``` yaml +azure-arm: true +csharp: true +library-name: storageactions +namespace: Azure.ResourceManager.storageactions +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/storageactions/resource-manager/readme.md +output-folder: $(this-folder)/Generated +clear-output-folder: true +sample-gen: + output-folder: $(this-folder)/../samples/Generated + clear-output-folder: true +skip-csproj: true +modelerfour: + flatten-payloads: false + +#mgmt-debug: +# show-serialized-names: true + + + +format-by-name-rules: + 'tenantId': 'uuid' + 'ETag': 'etag' + 'location': 'azure-location' + '*Uri': 'Uri' + '*Uris': 'Uri' + +acronym-mapping: + CPU: Cpu + CPUs: Cpus + Os: OS + Ip: IP + Ips: IPs|ips + ID: Id + IDs: Ids + VM: Vm + VMs: Vms + Vmos: VmOS + VMScaleSet: VmScaleSet + DNS: Dns + VPN: Vpn + NAT: Nat + WAN: Wan + Ipv4: IPv4|ipv4 + Ipv6: IPv6|ipv6 + Ipsec: IPsec|ipsec + SSO: Sso + URI: Uri + Etag: ETag|etag + +``` diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/tests/Azure.ResourceManager.Storageactions.Tests.csproj b/sdk/storageactions/Azure.ResourceManager.Storageactions/tests/Azure.ResourceManager.Storageactions.Tests.csproj new file mode 100644 index 000000000000..08e103d5a090 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/tests/Azure.ResourceManager.Storageactions.Tests.csproj @@ -0,0 +1,5 @@ + + + + + diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/tests/storageactionsManagementTestBase.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/tests/storageactionsManagementTestBase.cs new file mode 100644 index 000000000000..e9c1ba66f680 --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/tests/storageactionsManagementTestBase.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.Storageactions.Tests +{ + public class storageactionsManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected storageactionsManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected storageactionsManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + } +} diff --git a/sdk/storageactions/Azure.ResourceManager.Storageactions/tests/storageactionsManagementTestEnvironment.cs b/sdk/storageactions/Azure.ResourceManager.Storageactions/tests/storageactionsManagementTestEnvironment.cs new file mode 100644 index 000000000000..a02ed1ceca4f --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.Storageactions/tests/storageactionsManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.Storageactions.Tests +{ + public class storageactionsManagementTestEnvironment : TestEnvironment + { + } +} \ No newline at end of file diff --git a/sdk/storageactions/ci.mgmt.yml b/sdk/storageactions/ci.mgmt.yml new file mode 100644 index 000000000000..f938165b70aa --- /dev/null +++ b/sdk/storageactions/ci.mgmt.yml @@ -0,0 +1,24 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: none + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/storageactions/ci.mgmt.yml + - sdk/storageactions/Azure.ResourceManager.Storageactions/ + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: storageactions + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.Storageactions + safeName: AzureResourceManagerStorageactions