diff --git a/sdk/resourcemanager/ci.mgmt.yml b/sdk/resourcemanager/ci.mgmt.yml index ec5cfe18a1fcc..de87a0c7650e4 100644 --- a/sdk/resourcemanager/ci.mgmt.yml +++ b/sdk/resourcemanager/ci.mgmt.yml @@ -184,6 +184,7 @@ trigger: - sdk/support/Azure.ResourceManager.Support - sdk/synapse/Azure.ResourceManager.Synapse - sdk/trafficmanager/Azure.ResourceManager.TrafficManager + - sdk/trustedsigning/Azure.ResourceManager.TrustedSigning - sdk/voiceservices/Azure.ResourceManager.VoiceServices - sdk/webpubsub/Azure.ResourceManager.WebPubSub - sdk/websites/Azure.ResourceManager.AppService @@ -256,6 +257,7 @@ pr: - sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization - sdk/devcenter/Azure.ResourceManager.DevCenter - sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices + - sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry - sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate - sdk/devspaces/Azure.ResourceManager.DevSpaces - sdk/devtestlabs/Azure.ResourceManager.DevTestLabs @@ -374,6 +376,7 @@ pr: - sdk/support/Azure.ResourceManager.Support - sdk/synapse/Azure.ResourceManager.Synapse - sdk/trafficmanager/Azure.ResourceManager.TrafficManager + - sdk/trustedsigning/Azure.ResourceManager.TrustedSigning - sdk/voiceservices/Azure.ResourceManager.VoiceServices - sdk/webpubsub/Azure.ResourceManager.WebPubSub - sdk/websites/Azure.ResourceManager.AppService diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/Azure.ResourceManager.TrustedSigning.sln b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/Azure.ResourceManager.TrustedSigning.sln new file mode 100644 index 0000000000000..c1395a297012b --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/Azure.ResourceManager.TrustedSigning.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("{8263E172-CB04-4BDC-B98A-771ACC2C8CAA}") = "Azure.ResourceManager.TrustedSigning", "src\Azure.ResourceManager.TrustedSigning.csproj", "{7B1AB398-376A-44C7-A844-76092392AD26}" +EndProject +Project("{8263E172-CB04-4BDC-B98A-771ACC2C8CAA}") = "Azure.ResourceManager.TrustedSigning.Tests", "tests\Azure.ResourceManager.TrustedSigning.Tests.csproj", "{CA97DD50-D003-4629-BCEB-185A56CA5CD1}" +EndProject +Project("{8263E172-CB04-4BDC-B98A-771ACC2C8CAA}") = "Azure.ResourceManager.TrustedSigning.Samples", "samples\Azure.ResourceManager.TrustedSigning.Samples.csproj", "{A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}" +EndProject +Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D9DFBE81-A9D5-46D2-84FD-742C582C007F} + 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 + {7B1AB398-376A-44C7-A844-76092392AD26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7B1AB398-376A-44C7-A844-76092392AD26}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7B1AB398-376A-44C7-A844-76092392AD26}.Debug|x64.ActiveCfg = Debug|Any CPU + {7B1AB398-376A-44C7-A844-76092392AD26}.Debug|x64.Build.0 = Debug|Any CPU + {7B1AB398-376A-44C7-A844-76092392AD26}.Debug|x86.ActiveCfg = Debug|Any CPU + {7B1AB398-376A-44C7-A844-76092392AD26}.Debug|x86.Build.0 = Debug|Any CPU + {7B1AB398-376A-44C7-A844-76092392AD26}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B1AB398-376A-44C7-A844-76092392AD26}.Release|Any CPU.Build.0 = Release|Any CPU + {7B1AB398-376A-44C7-A844-76092392AD26}.Release|x64.ActiveCfg = Release|Any CPU + {7B1AB398-376A-44C7-A844-76092392AD26}.Release|x64.Build.0 = Release|Any CPU + {7B1AB398-376A-44C7-A844-76092392AD26}.Release|x86.ActiveCfg = Release|Any CPU + {7B1AB398-376A-44C7-A844-76092392AD26}.Release|x86.Build.0 = Release|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Debug|x64.ActiveCfg = Debug|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Debug|x64.Build.0 = Debug|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Debug|x86.ActiveCfg = Debug|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Debug|x86.Build.0 = Debug|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Release|Any CPU.Build.0 = Release|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Release|x64.ActiveCfg = Release|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Release|x64.Build.0 = Release|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Release|x86.ActiveCfg = Release|Any CPU + {CA97DD50-D003-4629-BCEB-185A56CA5CD1}.Release|x86.Build.0 = Release|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Debug|x64.ActiveCfg = Debug|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Debug|x64.Build.0 = Debug|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Debug|x86.ActiveCfg = Debug|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Debug|x86.Build.0 = Debug|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Release|Any CPU.Build.0 = Release|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Release|x64.ActiveCfg = Release|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Release|x64.Build.0 = Release|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Release|x86.ActiveCfg = Release|Any CPU + {A5AF7B73-74A0-4635-8478-8B5CBA90EEFE}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/CHANGELOG.md b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/CHANGELOG.md new file mode 100644 index 0000000000000..734a5b6e41379 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/CHANGELOG.md @@ -0,0 +1,17 @@ +# Release History + +## 1.0.0-beta.1 (2024-04-27) + +### 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). diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/Directory.Build.props b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/Directory.Build.props new file mode 100644 index 0000000000000..1a9611bd49242 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/README.md b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/README.md new file mode 100644 index 0000000000000..5659508fa6e99 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/README.md @@ -0,0 +1,87 @@ +# Microsoft Azure TrustedSigning management client library for .NET + +# Trusted Signing (formerly Azure Code Signing) is a Microsoft fully managed end-to-end signing solution that simplifies the process and empowers 3rd party developers to easily build and distribute applications. +# This is part of Microsoft’s commitment to an open, inclusive, and secure ecosystem. +# Simplifies the signing process with an intuitive experience in Azure +# Zero-touch certificate lifecycle management that is FIPS 140-2 Level 3 compliant. +# Integrations into leading developer toolsets. +# Supports Public Trust, Test, Private Trust, and CI policy signing scenarios. +# Timestamping service. +# Content confidential signing – meaning digest signing that is fast and reliable – your file never leaves your endpoint. + +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 TrustedSigning management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.TrustedSigning --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/ diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/api/Azure.ResourceManager.TrustedSigning.netstandard2.0.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/api/Azure.ResourceManager.TrustedSigning.netstandard2.0.cs new file mode 100644 index 0000000000000..8c88edae67d12 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/api/Azure.ResourceManager.TrustedSigning.netstandard2.0.cs @@ -0,0 +1,367 @@ +namespace Azure.ResourceManager.TrustedSigning +{ + public partial class TrustedSigningAccountCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected TrustedSigningAccountCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string accountName, Azure.ResourceManager.TrustedSigning.TrustedSigningAccountData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string accountName, Azure.ResourceManager.TrustedSigning.TrustedSigningAccountData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string accountName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string accountName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string accountName, 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 accountName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string accountName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string accountName, 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 TrustedSigningAccountData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TrustedSigningAccountData(Azure.Core.AzureLocation location) { } + public System.Uri AccountUri { get { throw null; } } + public Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.TrustedSigning.Models.TrustedSigningSkuName? SkuName { get { throw null; } set { } } + Azure.ResourceManager.TrustedSigning.TrustedSigningAccountData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.TrustedSigning.TrustedSigningAccountData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TrustedSigningAccountResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected TrustedSigningAccountResource() { } + public virtual Azure.ResourceManager.TrustedSigning.TrustedSigningAccountData 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 accountName) { 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.Response GetTrustedSigningCertificateProfile(string profileName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrustedSigningCertificateProfileAsync(string profileName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.TrustedSigning.TrustedSigningCertificateProfileCollection GetTrustedSigningCertificateProfiles() { 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.TrustedSigning.Models.TrustedSigningAccountPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class TrustedSigningCertificateProfileCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected TrustedSigningCertificateProfileCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string profileName, Azure.ResourceManager.TrustedSigning.TrustedSigningCertificateProfileData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string profileName, Azure.ResourceManager.TrustedSigning.TrustedSigningCertificateProfileData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string profileName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string profileName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string profileName, 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 profileName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string profileName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string profileName, 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 TrustedSigningCertificateProfileData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TrustedSigningCertificateProfileData() { } + public System.Collections.Generic.IReadOnlyList Certificates { get { throw null; } } + public string City { get { throw null; } } + public string CommonName { get { throw null; } } + public string Country { get { throw null; } } + public string EnhancedKeyUsage { get { throw null; } } + public string IdentityValidationId { get { throw null; } set { } } + public bool? IncludeCity { get { throw null; } set { } } + public bool? IncludeCountry { get { throw null; } set { } } + public bool? IncludePostalCode { get { throw null; } set { } } + public bool? IncludeState { get { throw null; } set { } } + public bool? IncludeStreetAddress { get { throw null; } set { } } + public string Organization { get { throw null; } } + public string OrganizationUnit { get { throw null; } } + public string PostalCode { get { throw null; } } + public Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType? ProfileType { get { throw null; } set { } } + public Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState? ProvisioningState { get { throw null; } } + public string State { get { throw null; } } + public Azure.ResourceManager.TrustedSigning.Models.CertificateProfileStatus? Status { get { throw null; } } + public string StreetAddress { get { throw null; } } + Azure.ResourceManager.TrustedSigning.TrustedSigningCertificateProfileData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.TrustedSigning.TrustedSigningCertificateProfileData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TrustedSigningCertificateProfileResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected TrustedSigningCertificateProfileResource() { } + public virtual Azure.ResourceManager.TrustedSigning.TrustedSigningCertificateProfileData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string accountName, string profileName) { 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.Response RevokeCertificate(Azure.ResourceManager.TrustedSigning.Models.RevokeCertificateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task RevokeCertificateAsync(Azure.ResourceManager.TrustedSigning.Models.RevokeCertificateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.TrustedSigning.TrustedSigningCertificateProfileData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.TrustedSigning.TrustedSigningCertificateProfileData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public static partial class TrustedSigningExtensions + { + public static Azure.Response CheckTrustedSigningAccountNameAvailability(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> CheckTrustedSigningAccountNameAvailabilityAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response GetTrustedSigningAccount(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string accountName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetTrustedSigningAccountAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string accountName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.TrustedSigning.TrustedSigningAccountResource GetTrustedSigningAccountResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.TrustedSigning.TrustedSigningAccountCollection GetTrustedSigningAccounts(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } + public static Azure.Pageable GetTrustedSigningAccounts(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetTrustedSigningAccountsAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.TrustedSigning.TrustedSigningCertificateProfileResource GetTrustedSigningCertificateProfileResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + } +} +namespace Azure.ResourceManager.TrustedSigning.Mocking +{ + public partial class MockableTrustedSigningArmClient : Azure.ResourceManager.ArmResource + { + protected MockableTrustedSigningArmClient() { } + public virtual Azure.ResourceManager.TrustedSigning.TrustedSigningAccountResource GetTrustedSigningAccountResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.TrustedSigning.TrustedSigningCertificateProfileResource GetTrustedSigningCertificateProfileResource(Azure.Core.ResourceIdentifier id) { throw null; } + } + public partial class MockableTrustedSigningResourceGroupResource : Azure.ResourceManager.ArmResource + { + protected MockableTrustedSigningResourceGroupResource() { } + public virtual Azure.Response GetTrustedSigningAccount(string accountName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrustedSigningAccountAsync(string accountName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.TrustedSigning.TrustedSigningAccountCollection GetTrustedSigningAccounts() { throw null; } + } + public partial class MockableTrustedSigningSubscriptionResource : Azure.ResourceManager.ArmResource + { + protected MockableTrustedSigningSubscriptionResource() { } + public virtual Azure.Response CheckTrustedSigningAccountNameAvailability(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CheckTrustedSigningAccountNameAvailabilityAsync(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetTrustedSigningAccounts(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetTrustedSigningAccountsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } +} +namespace Azure.ResourceManager.TrustedSigning.Models +{ + public static partial class ArmTrustedSigningModelFactory + { + public static Azure.ResourceManager.TrustedSigning.Models.RevokeCertificateContent RevokeCertificateContent(string serialNumber = null, string thumbprint = null, System.DateTimeOffset effectiveOn = default(System.DateTimeOffset), string reason = null, string remarks = null) { throw null; } + public static Azure.ResourceManager.TrustedSigning.TrustedSigningAccountData TrustedSigningAccountData(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), System.Uri accountUri = null, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningSkuName? skuName = default(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningSkuName?), Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState? provisioningState = default(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState?)) { throw null; } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameAvailabilityResult TrustedSigningAccountNameAvailabilityResult(bool? isNameAvailable = default(bool?), Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameUnavailabilityReason? reason = default(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameUnavailabilityReason?), string message = null) { throw null; } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificate TrustedSigningCertificate(string serialNumber = null, string subjectName = null, string thumbprint = null, System.DateTimeOffset? createOn = default(System.DateTimeOffset?), System.DateTimeOffset? expireOn = default(System.DateTimeOffset?), Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificateStatus? status = default(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificateStatus?), System.DateTimeOffset? requestedOn = default(System.DateTimeOffset?), System.DateTimeOffset? effectiveOn = default(System.DateTimeOffset?), string reason = null, string remarks = null, Azure.ResourceManager.TrustedSigning.Models.CertificateRevocationStatus? statusRevocationStatus = default(Azure.ResourceManager.TrustedSigning.Models.CertificateRevocationStatus?), string failureReason = null) { throw null; } + public static Azure.ResourceManager.TrustedSigning.TrustedSigningCertificateProfileData TrustedSigningCertificateProfileData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType? profileType = default(Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType?), string commonName = null, string organization = null, string organizationUnit = null, string streetAddress = null, bool? includeStreetAddress = default(bool?), string city = null, bool? includeCity = default(bool?), string state = null, bool? includeState = default(bool?), string country = null, bool? includeCountry = default(bool?), string postalCode = null, bool? includePostalCode = default(bool?), string enhancedKeyUsage = null, string identityValidationId = null, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState? provisioningState = default(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState?), Azure.ResourceManager.TrustedSigning.Models.CertificateProfileStatus? status = default(Azure.ResourceManager.TrustedSigning.Models.CertificateProfileStatus?), System.Collections.Generic.IEnumerable certificates = null) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct CertificateProfileStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public CertificateProfileStatus(string value) { throw null; } + public static Azure.ResourceManager.TrustedSigning.Models.CertificateProfileStatus Active { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.CertificateProfileStatus Disabled { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.CertificateProfileStatus Suspended { get { throw null; } } + public bool Equals(Azure.ResourceManager.TrustedSigning.Models.CertificateProfileStatus 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.TrustedSigning.Models.CertificateProfileStatus left, Azure.ResourceManager.TrustedSigning.Models.CertificateProfileStatus right) { throw null; } + public static implicit operator Azure.ResourceManager.TrustedSigning.Models.CertificateProfileStatus (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.TrustedSigning.Models.CertificateProfileStatus left, Azure.ResourceManager.TrustedSigning.Models.CertificateProfileStatus right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct CertificateProfileType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public CertificateProfileType(string value) { throw null; } + public static Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType PrivateTrust { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType PrivateTrustCIPolicy { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType PublicTrust { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType PublicTrustTest { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType VbsEnclave { get { throw null; } } + public bool Equals(Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType 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.TrustedSigning.Models.CertificateProfileType left, Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType right) { throw null; } + public static implicit operator Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType left, Azure.ResourceManager.TrustedSigning.Models.CertificateProfileType right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct CertificateRevocationStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public CertificateRevocationStatus(string value) { throw null; } + public static Azure.ResourceManager.TrustedSigning.Models.CertificateRevocationStatus Failed { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.CertificateRevocationStatus InProgress { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.CertificateRevocationStatus Succeeded { get { throw null; } } + public bool Equals(Azure.ResourceManager.TrustedSigning.Models.CertificateRevocationStatus 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.TrustedSigning.Models.CertificateRevocationStatus left, Azure.ResourceManager.TrustedSigning.Models.CertificateRevocationStatus right) { throw null; } + public static implicit operator Azure.ResourceManager.TrustedSigning.Models.CertificateRevocationStatus (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.TrustedSigning.Models.CertificateRevocationStatus left, Azure.ResourceManager.TrustedSigning.Models.CertificateRevocationStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class RevokeCertificateContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RevokeCertificateContent(string serialNumber, string thumbprint, System.DateTimeOffset effectiveOn, string reason) { } + public System.DateTimeOffset EffectiveOn { get { throw null; } } + public string Reason { get { throw null; } } + public string Remarks { get { throw null; } set { } } + public string SerialNumber { get { throw null; } } + public string Thumbprint { get { throw null; } } + Azure.ResourceManager.TrustedSigning.Models.RevokeCertificateContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.TrustedSigning.Models.RevokeCertificateContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TrustedSigningAccountNameAvailabilityContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TrustedSigningAccountNameAvailabilityContent(string name) { } + public string Name { get { throw null; } } + Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameAvailabilityContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameAvailabilityContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TrustedSigningAccountNameAvailabilityResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TrustedSigningAccountNameAvailabilityResult() { } + public bool? IsNameAvailable { get { throw null; } } + public string Message { get { throw null; } } + public Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameUnavailabilityReason? Reason { get { throw null; } } + Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameAvailabilityResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameAvailabilityResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TrustedSigningAccountNameUnavailabilityReason : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TrustedSigningAccountNameUnavailabilityReason(string value) { throw null; } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameUnavailabilityReason AccountNameInvalid { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameUnavailabilityReason AlreadyExists { get { throw null; } } + public bool Equals(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameUnavailabilityReason 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.TrustedSigning.Models.TrustedSigningAccountNameUnavailabilityReason left, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameUnavailabilityReason right) { throw null; } + public static implicit operator Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameUnavailabilityReason (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameUnavailabilityReason left, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountNameUnavailabilityReason right) { throw null; } + public override string ToString() { throw null; } + } + public partial class TrustedSigningAccountPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TrustedSigningAccountPatch() { } + public Azure.ResourceManager.TrustedSigning.Models.TrustedSigningSkuName? SkuName { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountPatch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.TrustedSigning.Models.TrustedSigningAccountPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TrustedSigningCertificate : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TrustedSigningCertificate() { } + public System.DateTimeOffset? CreateOn { get { throw null; } } + public System.DateTimeOffset? EffectiveOn { get { throw null; } } + public System.DateTimeOffset? ExpireOn { get { throw null; } } + public string FailureReason { get { throw null; } } + public string Reason { get { throw null; } } + public string Remarks { get { throw null; } } + public System.DateTimeOffset? RequestedOn { get { throw null; } } + public string SerialNumber { get { throw null; } } + public Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificateStatus? Status { get { throw null; } } + public Azure.ResourceManager.TrustedSigning.Models.CertificateRevocationStatus? StatusRevocationStatus { get { throw null; } } + public string SubjectName { get { throw null; } } + public string Thumbprint { get { throw null; } } + Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificate System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificate System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TrustedSigningCertificateStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TrustedSigningCertificateStatus(string value) { throw null; } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificateStatus Active { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificateStatus Expired { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificateStatus Revoked { get { throw null; } } + public bool Equals(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificateStatus 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.TrustedSigning.Models.TrustedSigningCertificateStatus left, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificateStatus right) { throw null; } + public static implicit operator Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificateStatus (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificateStatus left, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningCertificateStatus right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TrustedSigningProvisioningState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TrustedSigningProvisioningState(string value) { throw null; } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState Accepted { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState Canceled { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState Deleting { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState Failed { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState Succeeded { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState Updating { get { throw null; } } + public bool Equals(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState 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.TrustedSigning.Models.TrustedSigningProvisioningState left, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState right) { throw null; } + public static implicit operator Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState left, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningProvisioningState right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TrustedSigningSkuName : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TrustedSigningSkuName(string value) { throw null; } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningSkuName Basic { get { throw null; } } + public static Azure.ResourceManager.TrustedSigning.Models.TrustedSigningSkuName Premium { get { throw null; } } + public bool Equals(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningSkuName 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.TrustedSigning.Models.TrustedSigningSkuName left, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningSkuName right) { throw null; } + public static implicit operator Azure.ResourceManager.TrustedSigning.Models.TrustedSigningSkuName (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.TrustedSigning.Models.TrustedSigningSkuName left, Azure.ResourceManager.TrustedSigning.Models.TrustedSigningSkuName right) { throw null; } + public override string ToString() { throw null; } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/assets.json b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/assets.json new file mode 100644 index 0000000000000..ebc39fdf5aefe --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/trustedsigning/Azure.ResourceManager.TrustedSigning", + "Tag": "net/trustedsigning/Azure.ResourceManager.TrustedSigning_adf858d152" +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Azure.ResourceManager.TrustedSigning.Samples.csproj b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Azure.ResourceManager.TrustedSigning.Samples.csproj new file mode 100644 index 0000000000000..ea6a6694b88a2 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Azure.ResourceManager.TrustedSigning.Samples.csproj @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountCollection.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountCollection.cs new file mode 100644 index 0000000000000..5f50e049a6164 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountCollection.cs @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning.Samples +{ + public partial class Sample_TrustedSigningAccountCollection + { + // Lists trusted signing accounts within a resource group. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListsTrustedSigningAccountsWithinAResourceGroup() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_ListByResourceGroup.json + // this example is just showing the usage of "CodeSigningAccounts_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 = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this TrustedSigningAccountResource + TrustedSigningAccountCollection collection = resourceGroupResource.GetTrustedSigningAccounts(); + + // invoke the operation and iterate over the result + await foreach (TrustedSigningAccountResource 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 + TrustedSigningAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get a Trusted Signing Account + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetATrustedSigningAccount() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Get.json + // this example is just showing the usage of "CodeSigningAccounts_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 = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this TrustedSigningAccountResource + TrustedSigningAccountCollection collection = resourceGroupResource.GetTrustedSigningAccounts(); + + // invoke the operation + string accountName = "MyAccount"; + TrustedSigningAccountResource result = await collection.GetAsync(accountName); + + // 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 + TrustedSigningAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a Trusted Signing Account + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetATrustedSigningAccount() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Get.json + // this example is just showing the usage of "CodeSigningAccounts_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 = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this TrustedSigningAccountResource + TrustedSigningAccountCollection collection = resourceGroupResource.GetTrustedSigningAccounts(); + + // invoke the operation + string accountName = "MyAccount"; + bool result = await collection.ExistsAsync(accountName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get a Trusted Signing Account + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetATrustedSigningAccount() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Get.json + // this example is just showing the usage of "CodeSigningAccounts_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 = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this TrustedSigningAccountResource + TrustedSigningAccountCollection collection = resourceGroupResource.GetTrustedSigningAccounts(); + + // invoke the operation + string accountName = "MyAccount"; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + TrustedSigningAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // 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 + TrustedSigningAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // Create a trusted Signing Account. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateATrustedSigningAccount() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Create.json + // this example is just showing the usage of "CodeSigningAccounts_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 = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this TrustedSigningAccountResource + TrustedSigningAccountCollection collection = resourceGroupResource.GetTrustedSigningAccounts(); + + // invoke the operation + string accountName = "MyAccount"; + TrustedSigningAccountData data = new TrustedSigningAccountData(new AzureLocation("westus")) + { + SkuName = TrustedSigningSkuName.Basic, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + TrustedSigningAccountResource 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 + TrustedSigningAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountResource.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountResource.cs new file mode 100644 index 0000000000000..bf7b824bc2019 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountResource.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning.Samples +{ + public partial class Sample_TrustedSigningAccountResource + { + // Checks that the trusted signing account name is available. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CheckTrustedSigningAccountNameAvailability_ChecksThatTheTrustedSigningAccountNameIsAvailable() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_CheckNameAvailability.json + // this example is just showing the usage of "CodeSigningAccounts_CheckNameAvailability" 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 = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + TrustedSigningAccountNameAvailabilityContent content = new TrustedSigningAccountNameAvailabilityContent("sample-account", new ResourceType("placeholder")); + TrustedSigningAccountNameAvailabilityResult result = await subscriptionResource.CheckTrustedSigningAccountNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Lists trusted signing accounts within a subscription. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetTrustedSigningAccounts_ListsTrustedSigningAccountsWithinASubscription() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_ListBySubscription.json + // this example is just showing the usage of "CodeSigningAccounts_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 = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (TrustedSigningAccountResource item in subscriptionResource.GetTrustedSigningAccountsAsync()) + { + // 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 + TrustedSigningAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get a Trusted Signing Account + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetATrustedSigningAccount() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Get.json + // this example is just showing the usage of "CodeSigningAccounts_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 TrustedSigningAccountResource created on azure + // for more information of creating TrustedSigningAccountResource, please refer to the document of TrustedSigningAccountResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + ResourceIdentifier trustedSigningAccountResourceId = TrustedSigningAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + TrustedSigningAccountResource trustedSigningAccount = client.GetTrustedSigningAccountResource(trustedSigningAccountResourceId); + + // invoke the operation + TrustedSigningAccountResource result = await trustedSigningAccount.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 + TrustedSigningAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update a trusted signing account. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateATrustedSigningAccount() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Update.json + // this example is just showing the usage of "CodeSigningAccounts_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 TrustedSigningAccountResource created on azure + // for more information of creating TrustedSigningAccountResource, please refer to the document of TrustedSigningAccountResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + ResourceIdentifier trustedSigningAccountResourceId = TrustedSigningAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + TrustedSigningAccountResource trustedSigningAccount = client.GetTrustedSigningAccountResource(trustedSigningAccountResourceId); + + // invoke the operation + TrustedSigningAccountPatch patch = new TrustedSigningAccountPatch() + { + Tags = +{ +["key1"] = "value1", +}, + }; + ArmOperation lro = await trustedSigningAccount.UpdateAsync(WaitUntil.Completed, patch); + TrustedSigningAccountResource 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 + TrustedSigningAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Delete a trusted signing account. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteATrustedSigningAccount() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Delete.json + // this example is just showing the usage of "CodeSigningAccounts_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 TrustedSigningAccountResource created on azure + // for more information of creating TrustedSigningAccountResource, please refer to the document of TrustedSigningAccountResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + ResourceIdentifier trustedSigningAccountResourceId = TrustedSigningAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + TrustedSigningAccountResource trustedSigningAccount = client.GetTrustedSigningAccountResource(trustedSigningAccountResourceId); + + // invoke the operation + await trustedSigningAccount.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileCollection.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileCollection.cs new file mode 100644 index 0000000000000..dd66b702f9aed --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileCollection.cs @@ -0,0 +1,207 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning.Samples +{ + public partial class Sample_TrustedSigningCertificateProfileCollection + { + // List certificate profiles under a trusted signing account. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListCertificateProfilesUnderATrustedSigningAccount() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_ListByCodeSigningAccount.json + // this example is just showing the usage of "CertificateProfiles_ListByCodeSigningAccount" 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 TrustedSigningAccountResource created on azure + // for more information of creating TrustedSigningAccountResource, please refer to the document of TrustedSigningAccountResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + ResourceIdentifier trustedSigningAccountResourceId = TrustedSigningAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + TrustedSigningAccountResource trustedSigningAccount = client.GetTrustedSigningAccountResource(trustedSigningAccountResourceId); + + // get the collection of this TrustedSigningCertificateProfileResource + TrustedSigningCertificateProfileCollection collection = trustedSigningAccount.GetTrustedSigningCertificateProfiles(); + + // invoke the operation and iterate over the result + await foreach (TrustedSigningCertificateProfileResource 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 + TrustedSigningCertificateProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get details of a certificate profile. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetDetailsOfACertificateProfile() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Get.json + // this example is just showing the usage of "CertificateProfiles_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 TrustedSigningAccountResource created on azure + // for more information of creating TrustedSigningAccountResource, please refer to the document of TrustedSigningAccountResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + ResourceIdentifier trustedSigningAccountResourceId = TrustedSigningAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + TrustedSigningAccountResource trustedSigningAccount = client.GetTrustedSigningAccountResource(trustedSigningAccountResourceId); + + // get the collection of this TrustedSigningCertificateProfileResource + TrustedSigningCertificateProfileCollection collection = trustedSigningAccount.GetTrustedSigningCertificateProfiles(); + + // invoke the operation + string profileName = "profileA"; + TrustedSigningCertificateProfileResource result = await collection.GetAsync(profileName); + + // 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 + TrustedSigningCertificateProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get details of a certificate profile. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetDetailsOfACertificateProfile() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Get.json + // this example is just showing the usage of "CertificateProfiles_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 TrustedSigningAccountResource created on azure + // for more information of creating TrustedSigningAccountResource, please refer to the document of TrustedSigningAccountResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + ResourceIdentifier trustedSigningAccountResourceId = TrustedSigningAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + TrustedSigningAccountResource trustedSigningAccount = client.GetTrustedSigningAccountResource(trustedSigningAccountResourceId); + + // get the collection of this TrustedSigningCertificateProfileResource + TrustedSigningCertificateProfileCollection collection = trustedSigningAccount.GetTrustedSigningCertificateProfiles(); + + // invoke the operation + string profileName = "profileA"; + bool result = await collection.ExistsAsync(profileName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get details of a certificate profile. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetDetailsOfACertificateProfile() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Get.json + // this example is just showing the usage of "CertificateProfiles_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 TrustedSigningAccountResource created on azure + // for more information of creating TrustedSigningAccountResource, please refer to the document of TrustedSigningAccountResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + ResourceIdentifier trustedSigningAccountResourceId = TrustedSigningAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + TrustedSigningAccountResource trustedSigningAccount = client.GetTrustedSigningAccountResource(trustedSigningAccountResourceId); + + // get the collection of this TrustedSigningCertificateProfileResource + TrustedSigningCertificateProfileCollection collection = trustedSigningAccount.GetTrustedSigningCertificateProfiles(); + + // invoke the operation + string profileName = "profileA"; + NullableResponse response = await collection.GetIfExistsAsync(profileName); + TrustedSigningCertificateProfileResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // 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 + TrustedSigningCertificateProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // Create a certificate profile. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateACertificateProfile() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Create.json + // this example is just showing the usage of "CertificateProfiles_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 TrustedSigningAccountResource created on azure + // for more information of creating TrustedSigningAccountResource, please refer to the document of TrustedSigningAccountResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + ResourceIdentifier trustedSigningAccountResourceId = TrustedSigningAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + TrustedSigningAccountResource trustedSigningAccount = client.GetTrustedSigningAccountResource(trustedSigningAccountResourceId); + + // get the collection of this TrustedSigningCertificateProfileResource + TrustedSigningCertificateProfileCollection collection = trustedSigningAccount.GetTrustedSigningCertificateProfiles(); + + // invoke the operation + string profileName = "profileA"; + TrustedSigningCertificateProfileData data = new TrustedSigningCertificateProfileData() + { + ProfileType = CertificateProfileType.PublicTrust, + IncludeStreetAddress = false, + IncludePostalCode = true, + IdentityValidationId = "00000000-1234-5678-3333-444444444444", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + TrustedSigningCertificateProfileResource 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 + TrustedSigningCertificateProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileResource.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileResource.cs new file mode 100644 index 0000000000000..e0d74d1f52d4d --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileResource.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning.Samples +{ + public partial class Sample_TrustedSigningCertificateProfileResource + { + // Get details of a certificate profile. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetDetailsOfACertificateProfile() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Get.json + // this example is just showing the usage of "CertificateProfiles_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 TrustedSigningCertificateProfileResource created on azure + // for more information of creating TrustedSigningCertificateProfileResource, please refer to the document of TrustedSigningCertificateProfileResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + string profileName = "profileA"; + ResourceIdentifier trustedSigningCertificateProfileResourceId = TrustedSigningCertificateProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, profileName); + TrustedSigningCertificateProfileResource trustedSigningCertificateProfile = client.GetTrustedSigningCertificateProfileResource(trustedSigningCertificateProfileResourceId); + + // invoke the operation + TrustedSigningCertificateProfileResource result = await trustedSigningCertificateProfile.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 + TrustedSigningCertificateProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create a certificate profile. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateACertificateProfile() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Create.json + // this example is just showing the usage of "CertificateProfiles_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 TrustedSigningCertificateProfileResource created on azure + // for more information of creating TrustedSigningCertificateProfileResource, please refer to the document of TrustedSigningCertificateProfileResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + string profileName = "profileA"; + ResourceIdentifier trustedSigningCertificateProfileResourceId = TrustedSigningCertificateProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, profileName); + TrustedSigningCertificateProfileResource trustedSigningCertificateProfile = client.GetTrustedSigningCertificateProfileResource(trustedSigningCertificateProfileResourceId); + + // invoke the operation + TrustedSigningCertificateProfileData data = new TrustedSigningCertificateProfileData() + { + ProfileType = CertificateProfileType.PublicTrust, + IncludeStreetAddress = false, + IncludePostalCode = true, + IdentityValidationId = "00000000-1234-5678-3333-444444444444", + }; + ArmOperation lro = await trustedSigningCertificateProfile.UpdateAsync(WaitUntil.Completed, data); + TrustedSigningCertificateProfileResource 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 + TrustedSigningCertificateProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Delete a certificate profile. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteACertificateProfile() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Delete.json + // this example is just showing the usage of "CertificateProfiles_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 TrustedSigningCertificateProfileResource created on azure + // for more information of creating TrustedSigningCertificateProfileResource, please refer to the document of TrustedSigningCertificateProfileResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + string profileName = "profileA"; + ResourceIdentifier trustedSigningCertificateProfileResourceId = TrustedSigningCertificateProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, profileName); + TrustedSigningCertificateProfileResource trustedSigningCertificateProfile = client.GetTrustedSigningCertificateProfileResource(trustedSigningCertificateProfileResourceId); + + // invoke the operation + await trustedSigningCertificateProfile.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Revoke a certificate under a certificate profile. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task RevokeCertificate_RevokeACertificateUnderACertificateProfile() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_RevokeCertificate.json + // this example is just showing the usage of "CertificateProfiles_RevokeCertificate" 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 TrustedSigningCertificateProfileResource created on azure + // for more information of creating TrustedSigningCertificateProfileResource, please refer to the document of TrustedSigningCertificateProfileResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "MyResourceGroup"; + string accountName = "MyAccount"; + string profileName = "profileA"; + ResourceIdentifier trustedSigningCertificateProfileResourceId = TrustedSigningCertificateProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, profileName); + TrustedSigningCertificateProfileResource trustedSigningCertificateProfile = client.GetTrustedSigningCertificateProfileResource(trustedSigningCertificateProfileResourceId); + + // invoke the operation + RevokeCertificateContent content = new RevokeCertificateContent("xxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", DateTimeOffset.Parse("2023-11-12T23:40:25+00:00"), "KeyCompromised") + { + Remarks = "test", + }; + await trustedSigningCertificateProfile.RevokeCertificateAsync(content); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Azure.ResourceManager.TrustedSigning.csproj b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Azure.ResourceManager.TrustedSigning.csproj new file mode 100644 index 0000000000000..ec04ed95a27b9 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Azure.ResourceManager.TrustedSigning.csproj @@ -0,0 +1,8 @@ + + + 1.0.0-beta.1 + Azure.ResourceManager.TrustedSigning + Azure Resource Manager client SDK for Azure resource provider TrustedSigning. + azure;management;arm;resource manager;trustedsigning + + diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/ArmTrustedSigningModelFactory.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/ArmTrustedSigningModelFactory.cs new file mode 100644 index 0000000000000..b24481989a418 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/ArmTrustedSigningModelFactory.cs @@ -0,0 +1,163 @@ +// 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; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + /// Model factory for models. + public static partial class ArmTrustedSigningModelFactory + { + /// Initializes a new instance of . + /// A boolean value that indicates whether the name is available for you to use. If true, the name is available. If false, the name has already been taken or is invalid and cannot be used. + /// The reason that a trusted signing account name could not be used. The Reason element is only returned if nameAvailable is false. + /// An error message explaining the Reason value in more detail. + /// A new instance for mocking. + public static TrustedSigningAccountNameAvailabilityResult TrustedSigningAccountNameAvailabilityResult(bool? isNameAvailable = null, TrustedSigningAccountNameUnavailabilityReason? reason = null, string message = null) + { + return new TrustedSigningAccountNameAvailabilityResult(isNameAvailable, reason, message, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The URI of the trusted signing account which is used during signing files. + /// SKU of the trusted signing account. + /// Status of the current operation on trusted signing account. + /// A new instance for mocking. + public static TrustedSigningAccountData TrustedSigningAccountData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, Uri accountUri = null, TrustedSigningSkuName? skuName = null, TrustedSigningProvisioningState? provisioningState = null) + { + tags ??= new Dictionary(); + + return new TrustedSigningAccountData( + id, + name, + resourceType, + systemData, + tags, + location, + accountUri, + skuName.HasValue ? new TrustedSigningAccountSku(skuName.Value, serializedAdditionalRawData: null) : null, + provisioningState, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Profile type of the certificate. + /// Used as CN in the certificate subject name. + /// Used as O in the certificate subject name. + /// Used as OU in the private trust certificate subject name. + /// Used as STREET in the certificate subject name. + /// Whether to include STREET in the certificate subject name. + /// Used as L in the certificate subject name. + /// Whether to include L in the certificate subject name. Applicable only for private trust, private trust ci profile types. + /// Used as S in the certificate subject name. + /// Whether to include S in the certificate subject name. Applicable only for private trust, private trust ci profile types. + /// Used as C in the certificate subject name. + /// Whether to include C in the certificate subject name. Applicable only for private trust, private trust ci profile types. + /// Used as PC in the certificate subject name. + /// Whether to include PC in the certificate subject name. + /// Enhanced key usage of the certificate. + /// Identity validation id used for the certificate subject name. + /// Status of the current operation on certificate profile. + /// Status of the certificate profile. + /// List of renewed certificates. + /// A new instance for mocking. + public static TrustedSigningCertificateProfileData TrustedSigningCertificateProfileData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, CertificateProfileType? profileType = null, string commonName = null, string organization = null, string organizationUnit = null, string streetAddress = null, bool? includeStreetAddress = null, string city = null, bool? includeCity = null, string state = null, bool? includeState = null, string country = null, bool? includeCountry = null, string postalCode = null, bool? includePostalCode = null, string enhancedKeyUsage = null, string identityValidationId = null, TrustedSigningProvisioningState? provisioningState = null, CertificateProfileStatus? status = null, IEnumerable certificates = null) + { + certificates ??= new List(); + + return new TrustedSigningCertificateProfileData( + id, + name, + resourceType, + systemData, + profileType, + commonName, + organization, + organizationUnit, + streetAddress, + includeStreetAddress, + city, + includeCity, + state, + includeState, + country, + includeCountry, + postalCode, + includePostalCode, + enhancedKeyUsage, + identityValidationId, + provisioningState, + status, + certificates?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Serial number of the certificate. + /// Subject name of the certificate. + /// Thumbprint of the certificate. + /// Certificate created date. + /// Certificate expiry date. + /// Status of the certificate. + /// The timestamp when the revocation is requested. + /// The timestamp when the revocation is effective. + /// Reason for revocation. + /// Remarks for the revocation. + /// Status of the revocation. + /// Reason for the revocation failure. + /// A new instance for mocking. + public static TrustedSigningCertificate TrustedSigningCertificate(string serialNumber = null, string subjectName = null, string thumbprint = null, DateTimeOffset? createOn = null, DateTimeOffset? expireOn = null, TrustedSigningCertificateStatus? status = null, DateTimeOffset? requestedOn = null, DateTimeOffset? effectiveOn = null, string reason = null, string remarks = null, CertificateRevocationStatus? statusRevocationStatus = null, string failureReason = null) + { + return new TrustedSigningCertificate( + serialNumber, + subjectName, + thumbprint, + createOn, + expireOn, + status, + requestedOn, + effectiveOn, + reason, + remarks, + statusRevocationStatus, + failureReason, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Serial number of the certificate. + /// Thumbprint of the certificate. + /// The timestamp when the revocation is effective. + /// Reason for the revocation. + /// Remarks for the revocation. + /// A new instance for mocking. + public static RevokeCertificateContent RevokeCertificateContent(string serialNumber = null, string thumbprint = null, DateTimeOffset effectiveOn = default, string reason = null, string remarks = null) + { + return new RevokeCertificateContent( + serialNumber, + thumbprint, + effectiveOn, + reason, + remarks, + serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/MockableTrustedSigningArmClient.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/MockableTrustedSigningArmClient.cs new file mode 100644 index 0000000000000..5ae11f82dbe99 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/MockableTrustedSigningArmClient.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; + +namespace Azure.ResourceManager.TrustedSigning.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableTrustedSigningArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableTrustedSigningArmClient() + { + } + + /// 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 MockableTrustedSigningArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableTrustedSigningArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 resource ID of the resource to get. + /// Returns a object. + public virtual TrustedSigningAccountResource GetTrustedSigningAccountResource(ResourceIdentifier id) + { + TrustedSigningAccountResource.ValidateResourceId(id); + return new TrustedSigningAccountResource(Client, id); + } + + /// + /// 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 resource ID of the resource to get. + /// Returns a object. + public virtual TrustedSigningCertificateProfileResource GetTrustedSigningCertificateProfileResource(ResourceIdentifier id) + { + TrustedSigningCertificateProfileResource.ValidateResourceId(id); + return new TrustedSigningCertificateProfileResource(Client, id); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/MockableTrustedSigningResourceGroupResource.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/MockableTrustedSigningResourceGroupResource.cs new file mode 100644 index 0000000000000..8e306bbfb17cf --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/MockableTrustedSigningResourceGroupResource.cs @@ -0,0 +1,105 @@ +// 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.Core; + +namespace Azure.ResourceManager.TrustedSigning.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableTrustedSigningResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableTrustedSigningResourceGroupResource() + { + } + + /// 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 MockableTrustedSigningResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of TrustedSigningAccountResources in the ResourceGroupResource. + /// An object representing collection of TrustedSigningAccountResources and their operations over a TrustedSigningAccountResource. + public virtual TrustedSigningAccountCollection GetTrustedSigningAccounts() + { + return GetCachedClient(client => new TrustedSigningAccountCollection(client, Id)); + } + + /// + /// Get a trusted Signing Account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Trusted Signing account name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTrustedSigningAccountAsync(string accountName, CancellationToken cancellationToken = default) + { + return await GetTrustedSigningAccounts().GetAsync(accountName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a trusted Signing Account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Trusted Signing account name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTrustedSigningAccount(string accountName, CancellationToken cancellationToken = default) + { + return GetTrustedSigningAccounts().Get(accountName, cancellationToken); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/MockableTrustedSigningSubscriptionResource.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/MockableTrustedSigningSubscriptionResource.cs new file mode 100644 index 0000000000000..c045cd4d3f9d2 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/MockableTrustedSigningSubscriptionResource.cs @@ -0,0 +1,189 @@ +// 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.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning.Mocking +{ + /// A class to add extension methods to SubscriptionResource. + public partial class MockableTrustedSigningSubscriptionResource : ArmResource + { + private ClientDiagnostics _trustedSigningAccountCodeSigningAccountsClientDiagnostics; + private CodeSigningAccountsRestOperations _trustedSigningAccountCodeSigningAccountsRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableTrustedSigningSubscriptionResource() + { + } + + /// 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 MockableTrustedSigningSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics TrustedSigningAccountCodeSigningAccountsClientDiagnostics => _trustedSigningAccountCodeSigningAccountsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.TrustedSigning", TrustedSigningAccountResource.ResourceType.Namespace, Diagnostics); + private CodeSigningAccountsRestOperations TrustedSigningAccountCodeSigningAccountsRestClient => _trustedSigningAccountCodeSigningAccountsRestClient ??= new CodeSigningAccountsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(TrustedSigningAccountResource.ResourceType)); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Checks that the trusted signing account name is valid and is not already in use. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CodeSigning/checkNameAvailability + /// + /// + /// Operation Id + /// CodeSigningAccounts_CheckNameAvailability + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The CheckAvailability request. + /// The cancellation token to use. + /// is null. + public virtual async Task> CheckTrustedSigningAccountNameAvailabilityAsync(TrustedSigningAccountNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = TrustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("MockableTrustedSigningSubscriptionResource.CheckTrustedSigningAccountNameAvailability"); + scope.Start(); + try + { + var response = await TrustedSigningAccountCodeSigningAccountsRestClient.CheckNameAvailabilityAsync(Id.SubscriptionId, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks that the trusted signing account name is valid and is not already in use. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CodeSigning/checkNameAvailability + /// + /// + /// Operation Id + /// CodeSigningAccounts_CheckNameAvailability + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The CheckAvailability request. + /// The cancellation token to use. + /// is null. + public virtual Response CheckTrustedSigningAccountNameAvailability(TrustedSigningAccountNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = TrustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("MockableTrustedSigningSubscriptionResource.CheckTrustedSigningAccountNameAvailability"); + scope.Start(); + try + { + var response = TrustedSigningAccountCodeSigningAccountsRestClient.CheckNameAvailability(Id.SubscriptionId, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists trusted signing accounts within a subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CodeSigning/codeSigningAccounts + /// + /// + /// Operation Id + /// CodeSigningAccounts_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetTrustedSigningAccountsAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => TrustedSigningAccountCodeSigningAccountsRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => TrustedSigningAccountCodeSigningAccountsRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new TrustedSigningAccountResource(Client, TrustedSigningAccountData.DeserializeTrustedSigningAccountData(e)), TrustedSigningAccountCodeSigningAccountsClientDiagnostics, Pipeline, "MockableTrustedSigningSubscriptionResource.GetTrustedSigningAccounts", "value", "nextLink", cancellationToken); + } + + /// + /// Lists trusted signing accounts within a subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CodeSigning/codeSigningAccounts + /// + /// + /// Operation Id + /// CodeSigningAccounts_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetTrustedSigningAccounts(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => TrustedSigningAccountCodeSigningAccountsRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => TrustedSigningAccountCodeSigningAccountsRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TrustedSigningAccountResource(Client, TrustedSigningAccountData.DeserializeTrustedSigningAccountData(e)), TrustedSigningAccountCodeSigningAccountsClientDiagnostics, Pipeline, "MockableTrustedSigningSubscriptionResource.GetTrustedSigningAccounts", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/TrustedSigningExtensions.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/TrustedSigningExtensions.cs new file mode 100644 index 0000000000000..eb40875d5f75f --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Extensions/TrustedSigningExtensions.cs @@ -0,0 +1,311 @@ +// 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.Core; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TrustedSigning.Mocking; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning +{ + /// A class to add extension methods to Azure.ResourceManager.TrustedSigning. + public static partial class TrustedSigningExtensions + { + private static MockableTrustedSigningArmClient GetMockableTrustedSigningArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableTrustedSigningArmClient(client0)); + } + + private static MockableTrustedSigningResourceGroupResource GetMockableTrustedSigningResourceGroupResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableTrustedSigningResourceGroupResource(client, resource.Id)); + } + + private static MockableTrustedSigningSubscriptionResource GetMockableTrustedSigningSubscriptionResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableTrustedSigningSubscriptionResource(client, resource.Id)); + } + + /// + /// 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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static TrustedSigningAccountResource GetTrustedSigningAccountResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableTrustedSigningArmClient(client).GetTrustedSigningAccountResource(id); + } + + /// + /// 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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static TrustedSigningCertificateProfileResource GetTrustedSigningCertificateProfileResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableTrustedSigningArmClient(client).GetTrustedSigningCertificateProfileResource(id); + } + + /// + /// Gets a collection of TrustedSigningAccountResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// is null. + /// An object representing collection of TrustedSigningAccountResources and their operations over a TrustedSigningAccountResource. + public static TrustedSigningAccountCollection GetTrustedSigningAccounts(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableTrustedSigningResourceGroupResource(resourceGroupResource).GetTrustedSigningAccounts(); + } + + /// + /// Get a trusted Signing Account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Trusted Signing account name. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetTrustedSigningAccountAsync(this ResourceGroupResource resourceGroupResource, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableTrustedSigningResourceGroupResource(resourceGroupResource).GetTrustedSigningAccountAsync(accountName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a trusted Signing Account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Trusted Signing account name. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetTrustedSigningAccount(this ResourceGroupResource resourceGroupResource, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableTrustedSigningResourceGroupResource(resourceGroupResource).GetTrustedSigningAccount(accountName, cancellationToken); + } + + /// + /// Checks that the trusted signing account name is valid and is not already in use. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CodeSigning/checkNameAvailability + /// + /// + /// Operation Id + /// CodeSigningAccounts_CheckNameAvailability + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The CheckAvailability request. + /// The cancellation token to use. + /// or is null. + public static async Task> CheckTrustedSigningAccountNameAvailabilityAsync(this SubscriptionResource subscriptionResource, TrustedSigningAccountNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableTrustedSigningSubscriptionResource(subscriptionResource).CheckTrustedSigningAccountNameAvailabilityAsync(content, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks that the trusted signing account name is valid and is not already in use. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CodeSigning/checkNameAvailability + /// + /// + /// Operation Id + /// CodeSigningAccounts_CheckNameAvailability + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The CheckAvailability request. + /// The cancellation token to use. + /// or is null. + public static Response CheckTrustedSigningAccountNameAvailability(this SubscriptionResource subscriptionResource, TrustedSigningAccountNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableTrustedSigningSubscriptionResource(subscriptionResource).CheckTrustedSigningAccountNameAvailability(content, cancellationToken); + } + + /// + /// Lists trusted signing accounts within a subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CodeSigning/codeSigningAccounts + /// + /// + /// Operation Id + /// CodeSigningAccounts_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetTrustedSigningAccountsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableTrustedSigningSubscriptionResource(subscriptionResource).GetTrustedSigningAccountsAsync(cancellationToken); + } + + /// + /// Lists trusted signing accounts within a subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CodeSigning/codeSigningAccounts + /// + /// + /// Operation Id + /// CodeSigningAccounts_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetTrustedSigningAccounts(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableTrustedSigningSubscriptionResource(subscriptionResource).GetTrustedSigningAccounts(cancellationToken); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/Argument.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/Argument.cs new file mode 100644 index 0000000000000..ce5b5dbb3d29b --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.TrustedSigning +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", name); + } + } + + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 0000000000000..609fd8263ab19 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.TrustedSigning +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/ChangeTrackingList.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 0000000000000..3f69a4d4fae92 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// 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.Linq; + +namespace Azure.ResourceManager.TrustedSigning +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 0000000000000..bb5af249757f8 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,396 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.ResourceManager.TrustedSigning +{ + internal static class ModelSerializationExtensions + { + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? new ModelReaderWriterOptions("W")); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/Optional.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/Optional.cs new file mode 100644 index 0000000000000..2e7270e30daf0 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.TrustedSigning +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 0000000000000..3f98801e2864c --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.TrustedSigning +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningAccountOperationSource.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningAccountOperationSource.cs new file mode 100644 index 0000000000000..aba7d4a717634 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningAccountOperationSource.cs @@ -0,0 +1,38 @@ +// 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.Core; + +namespace Azure.ResourceManager.TrustedSigning +{ + internal class TrustedSigningAccountOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal TrustedSigningAccountOperationSource(ArmClient client) + { + _client = client; + } + + TrustedSigningAccountResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = TrustedSigningAccountData.DeserializeTrustedSigningAccountData(document.RootElement); + return new TrustedSigningAccountResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = TrustedSigningAccountData.DeserializeTrustedSigningAccountData(document.RootElement); + return new TrustedSigningAccountResource(_client, data); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningArmOperation.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningArmOperation.cs new file mode 100644 index 0000000000000..6c8ace6808166 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningArmOperation.cs @@ -0,0 +1,68 @@ +// 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.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.TrustedSigning +{ +#pragma warning disable SA1649 // File name should match first type name + internal class TrustedSigningArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + + /// Initializes a new instance of TrustedSigningArmOperation for mocking. + protected TrustedSigningArmOperation() + { + } + + internal TrustedSigningArmOperation(Response response) + { + _operation = OperationInternal.Succeeded(response); + } + + internal TrustedSigningArmOperation(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, "TrustedSigningArmOperation", 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningArmOperationOfT.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningArmOperationOfT.cs new file mode 100644 index 0000000000000..2f18e89f229da --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningArmOperationOfT.cs @@ -0,0 +1,74 @@ +// 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.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.TrustedSigning +{ +#pragma warning disable SA1649 // File name should match first type name + internal class TrustedSigningArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + + /// Initializes a new instance of TrustedSigningArmOperation for mocking. + protected TrustedSigningArmOperation() + { + } + + internal TrustedSigningArmOperation(Response response) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + } + + internal TrustedSigningArmOperation(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, "TrustedSigningArmOperation", 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningCertificateProfileOperationSource.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningCertificateProfileOperationSource.cs new file mode 100644 index 0000000000000..e613e5c2ddde5 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/LongRunningOperation/TrustedSigningCertificateProfileOperationSource.cs @@ -0,0 +1,38 @@ +// 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.Core; + +namespace Azure.ResourceManager.TrustedSigning +{ + internal class TrustedSigningCertificateProfileOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal TrustedSigningCertificateProfileOperationSource(ArmClient client) + { + _client = client; + } + + TrustedSigningCertificateProfileResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = TrustedSigningCertificateProfileData.DeserializeTrustedSigningCertificateProfileData(document.RootElement); + return new TrustedSigningCertificateProfileResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = TrustedSigningCertificateProfileData.DeserializeTrustedSigningCertificateProfileData(document.RootElement); + return new TrustedSigningCertificateProfileResource(_client, data); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileListResult.Serialization.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileListResult.Serialization.cs new file mode 100644 index 0000000000000..ac98a583e3b12 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileListResult.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + internal partial class CertificateProfileListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertificateProfileListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CertificateProfileListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertificateProfileListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCertificateProfileListResult(document.RootElement, options); + } + + internal static CertificateProfileListResult DeserializeCertificateProfileListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TrustedSigningCertificateProfileData.DeserializeTrustedSigningCertificateProfileData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CertificateProfileListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CertificateProfileListResult)} does not support writing '{options.Format}' format."); + } + } + + CertificateProfileListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCertificateProfileListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CertificateProfileListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileListResult.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileListResult.cs new file mode 100644 index 0000000000000..b031a9bd303db --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + /// The response of a CertificateProfile list operation. + internal partial class CertificateProfileListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The CertificateProfile items on this page. + /// is null. + internal CertificateProfileListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The CertificateProfile items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal CertificateProfileListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CertificateProfileListResult() + { + } + + /// The CertificateProfile items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileStatus.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileStatus.cs new file mode 100644 index 0000000000000..451e5f777fa6f --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileStatus.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.TrustedSigning.Models +{ + /// Status of the certificate profiles. + public readonly partial struct CertificateProfileStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CertificateProfileStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ActiveValue = "Active"; + private const string DisabledValue = "Disabled"; + private const string SuspendedValue = "Suspended"; + + /// The certificate profile is active. + public static CertificateProfileStatus Active { get; } = new CertificateProfileStatus(ActiveValue); + /// The certificate profile is disabled. + public static CertificateProfileStatus Disabled { get; } = new CertificateProfileStatus(DisabledValue); + /// The certificate profile is suspended. + public static CertificateProfileStatus Suspended { get; } = new CertificateProfileStatus(SuspendedValue); + /// Determines if two values are the same. + public static bool operator ==(CertificateProfileStatus left, CertificateProfileStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CertificateProfileStatus left, CertificateProfileStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CertificateProfileStatus(string value) => new CertificateProfileStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CertificateProfileStatus other && Equals(other); + /// + public bool Equals(CertificateProfileStatus 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileType.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileType.cs new file mode 100644 index 0000000000000..781b72ceaaff5 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateProfileType.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + /// Type of the certificate. + public readonly partial struct CertificateProfileType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CertificateProfileType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PublicTrustValue = "PublicTrust"; + private const string PrivateTrustValue = "PrivateTrust"; + private const string PrivateTrustCIPolicyValue = "PrivateTrustCIPolicy"; + private const string VbsEnclaveValue = "VBSEnclave"; + private const string PublicTrustTestValue = "PublicTrustTest"; + + /// Used for signing files which are distributed publicly. + public static CertificateProfileType PublicTrust { get; } = new CertificateProfileType(PublicTrustValue); + /// Used for signing files which are distributed internally within organization or group boundary. + public static CertificateProfileType PrivateTrust { get; } = new CertificateProfileType(PrivateTrustValue); + /// Used for signing CI policy files. + public static CertificateProfileType PrivateTrustCIPolicy { get; } = new CertificateProfileType(PrivateTrustCIPolicyValue); + /// Used for signing files which are run in secure vbs enclave. + public static CertificateProfileType VbsEnclave { get; } = new CertificateProfileType(VbsEnclaveValue); + /// Used for signing files for testing purpose. + public static CertificateProfileType PublicTrustTest { get; } = new CertificateProfileType(PublicTrustTestValue); + /// Determines if two values are the same. + public static bool operator ==(CertificateProfileType left, CertificateProfileType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CertificateProfileType left, CertificateProfileType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CertificateProfileType(string value) => new CertificateProfileType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CertificateProfileType other && Equals(other); + /// + public bool Equals(CertificateProfileType 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateRevocationStatus.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateRevocationStatus.cs new file mode 100644 index 0000000000000..99aaf547be6d2 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CertificateRevocationStatus.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.TrustedSigning.Models +{ + /// Revocation status of the certificate. + public readonly partial struct CertificateRevocationStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CertificateRevocationStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string InProgressValue = "InProgress"; + private const string FailedValue = "Failed"; + + /// Certificate revocation succeeded. + public static CertificateRevocationStatus Succeeded { get; } = new CertificateRevocationStatus(SucceededValue); + /// Certificate revocation is in progress. + public static CertificateRevocationStatus InProgress { get; } = new CertificateRevocationStatus(InProgressValue); + /// Certificate revocation failed. + public static CertificateRevocationStatus Failed { get; } = new CertificateRevocationStatus(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(CertificateRevocationStatus left, CertificateRevocationStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CertificateRevocationStatus left, CertificateRevocationStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CertificateRevocationStatus(string value) => new CertificateRevocationStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CertificateRevocationStatus other && Equals(other); + /// + public bool Equals(CertificateRevocationStatus 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CodeSigningAccountListResult.Serialization.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CodeSigningAccountListResult.Serialization.cs new file mode 100644 index 0000000000000..819bd65c7fc1d --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CodeSigningAccountListResult.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + internal partial class CodeSigningAccountListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CodeSigningAccountListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CodeSigningAccountListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CodeSigningAccountListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCodeSigningAccountListResult(document.RootElement, options); + } + + internal static CodeSigningAccountListResult DeserializeCodeSigningAccountListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TrustedSigningAccountData.DeserializeTrustedSigningAccountData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CodeSigningAccountListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CodeSigningAccountListResult)} does not support writing '{options.Format}' format."); + } + } + + CodeSigningAccountListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCodeSigningAccountListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CodeSigningAccountListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CodeSigningAccountListResult.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CodeSigningAccountListResult.cs new file mode 100644 index 0000000000000..c16cff68f01bc --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/CodeSigningAccountListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + /// The response of a CodeSigningAccount list operation. + internal partial class CodeSigningAccountListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The CodeSigningAccount items on this page. + /// is null. + internal CodeSigningAccountListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The CodeSigningAccount items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal CodeSigningAccountListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CodeSigningAccountListResult() + { + } + + /// The CodeSigningAccount items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/RevokeCertificateContent.Serialization.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/RevokeCertificateContent.Serialization.cs new file mode 100644 index 0000000000000..c7ba972615c43 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/RevokeCertificateContent.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + public partial class RevokeCertificateContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RevokeCertificateContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("serialNumber"u8); + writer.WriteStringValue(SerialNumber); + writer.WritePropertyName("thumbprint"u8); + writer.WriteStringValue(Thumbprint); + writer.WritePropertyName("effectiveAt"u8); + writer.WriteStringValue(EffectiveOn, "O"); + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason); + if (Optional.IsDefined(Remarks)) + { + writer.WritePropertyName("remarks"u8); + writer.WriteStringValue(Remarks); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RevokeCertificateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RevokeCertificateContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRevokeCertificateContent(document.RootElement, options); + } + + internal static RevokeCertificateContent DeserializeRevokeCertificateContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string serialNumber = default; + string thumbprint = default; + DateTimeOffset effectiveAt = default; + string reason = default; + string remarks = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("serialNumber"u8)) + { + serialNumber = property.Value.GetString(); + continue; + } + if (property.NameEquals("thumbprint"u8)) + { + thumbprint = property.Value.GetString(); + continue; + } + if (property.NameEquals("effectiveAt"u8)) + { + effectiveAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("reason"u8)) + { + reason = property.Value.GetString(); + continue; + } + if (property.NameEquals("remarks"u8)) + { + remarks = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RevokeCertificateContent( + serialNumber, + thumbprint, + effectiveAt, + reason, + remarks, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RevokeCertificateContent)} does not support writing '{options.Format}' format."); + } + } + + RevokeCertificateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRevokeCertificateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RevokeCertificateContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/RevokeCertificateContent.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/RevokeCertificateContent.cs new file mode 100644 index 0000000000000..6f4440ffbc5c4 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/RevokeCertificateContent.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + /// Defines the certificate revocation properties. + public partial class RevokeCertificateContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Serial number of the certificate. + /// Thumbprint of the certificate. + /// The timestamp when the revocation is effective. + /// Reason for the revocation. + /// , or is null. + public RevokeCertificateContent(string serialNumber, string thumbprint, DateTimeOffset effectiveOn, string reason) + { + Argument.AssertNotNull(serialNumber, nameof(serialNumber)); + Argument.AssertNotNull(thumbprint, nameof(thumbprint)); + Argument.AssertNotNull(reason, nameof(reason)); + + SerialNumber = serialNumber; + Thumbprint = thumbprint; + EffectiveOn = effectiveOn; + Reason = reason; + } + + /// Initializes a new instance of . + /// Serial number of the certificate. + /// Thumbprint of the certificate. + /// The timestamp when the revocation is effective. + /// Reason for the revocation. + /// Remarks for the revocation. + /// Keeps track of any properties unknown to the library. + internal RevokeCertificateContent(string serialNumber, string thumbprint, DateTimeOffset effectiveOn, string reason, string remarks, IDictionary serializedAdditionalRawData) + { + SerialNumber = serialNumber; + Thumbprint = thumbprint; + EffectiveOn = effectiveOn; + Reason = reason; + Remarks = remarks; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RevokeCertificateContent() + { + } + + /// Serial number of the certificate. + public string SerialNumber { get; } + /// Thumbprint of the certificate. + public string Thumbprint { get; } + /// The timestamp when the revocation is effective. + public DateTimeOffset EffectiveOn { get; } + /// Reason for the revocation. + public string Reason { get; } + /// Remarks for the revocation. + public string Remarks { get; set; } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityContent.Serialization.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityContent.Serialization.cs new file mode 100644 index 0000000000000..b0d509303132d --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityContent.Serialization.cs @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + public partial class TrustedSigningAccountNameAvailabilityContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningAccountNameAvailabilityContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TrustedSigningAccountNameAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningAccountNameAvailabilityContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrustedSigningAccountNameAvailabilityContent(document.RootElement, options); + } + + internal static TrustedSigningAccountNameAvailabilityContent DeserializeTrustedSigningAccountNameAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + ResourceType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TrustedSigningAccountNameAvailabilityContent(name, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TrustedSigningAccountNameAvailabilityContent)} does not support writing '{options.Format}' format."); + } + } + + TrustedSigningAccountNameAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTrustedSigningAccountNameAvailabilityContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrustedSigningAccountNameAvailabilityContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityContent.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityContent.cs new file mode 100644 index 0000000000000..22d0c7a134bdf --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityContent.cs @@ -0,0 +1,82 @@ +// 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.TrustedSigning.Models +{ + /// The parameters used to check the availability of the trusted signing account name. + public partial class TrustedSigningAccountNameAvailabilityContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Trusted signing account name. + /// The type of the resource, "Microsoft.CodeSigning/codeSigningAccounts". + /// is null. + public TrustedSigningAccountNameAvailabilityContent(string name, ResourceType resourceType) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + ResourceType = resourceType; + } + + /// Initializes a new instance of . + /// Trusted signing account name. + /// The type of the resource, "Microsoft.CodeSigning/codeSigningAccounts". + /// Keeps track of any properties unknown to the library. + internal TrustedSigningAccountNameAvailabilityContent(string name, ResourceType resourceType, IDictionary serializedAdditionalRawData) + { + Name = name; + ResourceType = resourceType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TrustedSigningAccountNameAvailabilityContent() + { + } + + /// Trusted signing account name. + public string Name { get; } + /// The type of the resource, "Microsoft.CodeSigning/codeSigningAccounts". + public ResourceType ResourceType { get; } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityResult.Serialization.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityResult.Serialization.cs new file mode 100644 index 0000000000000..34e3a15d0193f --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityResult.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + public partial class TrustedSigningAccountNameAvailabilityResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningAccountNameAvailabilityResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(IsNameAvailable)) + { + writer.WritePropertyName("nameAvailable"u8); + writer.WriteBooleanValue(IsNameAvailable.Value); + } + if (options.Format != "W" && Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TrustedSigningAccountNameAvailabilityResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningAccountNameAvailabilityResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrustedSigningAccountNameAvailabilityResult(document.RootElement, options); + } + + internal static TrustedSigningAccountNameAvailabilityResult DeserializeTrustedSigningAccountNameAvailabilityResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? nameAvailable = default; + TrustedSigningAccountNameUnavailabilityReason? reason = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("nameAvailable"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nameAvailable = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("reason"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + reason = new TrustedSigningAccountNameUnavailabilityReason(property.Value.GetString()); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TrustedSigningAccountNameAvailabilityResult(nameAvailable, reason, message, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TrustedSigningAccountNameAvailabilityResult)} does not support writing '{options.Format}' format."); + } + } + + TrustedSigningAccountNameAvailabilityResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTrustedSigningAccountNameAvailabilityResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrustedSigningAccountNameAvailabilityResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityResult.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityResult.cs new file mode 100644 index 0000000000000..9d289165077d0 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameAvailabilityResult.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + /// The CheckNameAvailability operation response. + public partial class TrustedSigningAccountNameAvailabilityResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal TrustedSigningAccountNameAvailabilityResult() + { + } + + /// Initializes a new instance of . + /// A boolean value that indicates whether the name is available for you to use. If true, the name is available. If false, the name has already been taken or is invalid and cannot be used. + /// The reason that a trusted signing account name could not be used. The Reason element is only returned if nameAvailable is false. + /// An error message explaining the Reason value in more detail. + /// Keeps track of any properties unknown to the library. + internal TrustedSigningAccountNameAvailabilityResult(bool? isNameAvailable, TrustedSigningAccountNameUnavailabilityReason? reason, string message, IDictionary serializedAdditionalRawData) + { + IsNameAvailable = isNameAvailable; + Reason = reason; + Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A boolean value that indicates whether the name is available for you to use. If true, the name is available. If false, the name has already been taken or is invalid and cannot be used. + public bool? IsNameAvailable { get; } + /// The reason that a trusted signing account name could not be used. The Reason element is only returned if nameAvailable is false. + public TrustedSigningAccountNameUnavailabilityReason? Reason { get; } + /// An error message explaining the Reason value in more detail. + public string Message { get; } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameUnavailabilityReason.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameUnavailabilityReason.cs new file mode 100644 index 0000000000000..a3e9ace11a773 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountNameUnavailabilityReason.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.TrustedSigning.Models +{ + /// The reason that a trusted signing account name could not be used. The Reason element is only returned if nameAvailable is false. + public readonly partial struct TrustedSigningAccountNameUnavailabilityReason : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TrustedSigningAccountNameUnavailabilityReason(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AccountNameInvalidValue = "AccountNameInvalid"; + private const string AlreadyExistsValue = "AlreadyExists"; + + /// Account name is invalid. + public static TrustedSigningAccountNameUnavailabilityReason AccountNameInvalid { get; } = new TrustedSigningAccountNameUnavailabilityReason(AccountNameInvalidValue); + /// Account name already exists. + public static TrustedSigningAccountNameUnavailabilityReason AlreadyExists { get; } = new TrustedSigningAccountNameUnavailabilityReason(AlreadyExistsValue); + /// Determines if two values are the same. + public static bool operator ==(TrustedSigningAccountNameUnavailabilityReason left, TrustedSigningAccountNameUnavailabilityReason right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TrustedSigningAccountNameUnavailabilityReason left, TrustedSigningAccountNameUnavailabilityReason right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator TrustedSigningAccountNameUnavailabilityReason(string value) => new TrustedSigningAccountNameUnavailabilityReason(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TrustedSigningAccountNameUnavailabilityReason other && Equals(other); + /// + public bool Equals(TrustedSigningAccountNameUnavailabilityReason 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountPatch.Serialization.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountPatch.Serialization.cs new file mode 100644 index 0000000000000..f3ce266cf1ef5 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountPatch.Serialization.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + public partial class TrustedSigningAccountPatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningAccountPatch)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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(Sku)) + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TrustedSigningAccountPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningAccountPatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrustedSigningAccountPatch(document.RootElement, options); + } + + internal static TrustedSigningAccountPatch DeserializeTrustedSigningAccountPatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + TrustedSigningAccountSku sku = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + 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("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("sku"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sku = TrustedSigningAccountSku.DeserializeTrustedSigningAccountSku(property0.Value, options); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TrustedSigningAccountPatch(tags ?? new ChangeTrackingDictionary(), sku, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TrustedSigningAccountPatch)} does not support writing '{options.Format}' format."); + } + } + + TrustedSigningAccountPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTrustedSigningAccountPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrustedSigningAccountPatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountPatch.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountPatch.cs new file mode 100644 index 0000000000000..16b227baeea5e --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountPatch.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + /// Parameters for creating or updating a trusted signing account. + public partial class TrustedSigningAccountPatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TrustedSigningAccountPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Resource tags. + /// SKU of the trusted signing account. + /// Keeps track of any properties unknown to the library. + internal TrustedSigningAccountPatch(IDictionary tags, TrustedSigningAccountSku sku, IDictionary serializedAdditionalRawData) + { + Tags = tags; + Sku = sku; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource tags. + public IDictionary Tags { get; } + /// SKU of the trusted signing account. + internal TrustedSigningAccountSku Sku { get; set; } + /// Name of the SKU. + public TrustedSigningSkuName? SkuName + { + get => Sku is null ? default(TrustedSigningSkuName?) : Sku.Name; + set + { + Sku = value.HasValue ? new TrustedSigningAccountSku(value.Value) : null; + } + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountSku.Serialization.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountSku.Serialization.cs new file mode 100644 index 0000000000000..f266f134d60c7 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountSku.Serialization.cs @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + internal partial class TrustedSigningAccountSku : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningAccountSku)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TrustedSigningAccountSku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningAccountSku)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrustedSigningAccountSku(document.RootElement, options); + } + + internal static TrustedSigningAccountSku DeserializeTrustedSigningAccountSku(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TrustedSigningSkuName name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = new TrustedSigningSkuName(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TrustedSigningAccountSku(name, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TrustedSigningAccountSku)} does not support writing '{options.Format}' format."); + } + } + + TrustedSigningAccountSku IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTrustedSigningAccountSku(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrustedSigningAccountSku)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountSku.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountSku.cs new file mode 100644 index 0000000000000..6395182def73b --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningAccountSku.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + /// SKU of the trusted signing account. + internal partial class TrustedSigningAccountSku + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Name of the SKU. + public TrustedSigningAccountSku(TrustedSigningSkuName name) + { + Name = name; + } + + /// Initializes a new instance of . + /// Name of the SKU. + /// Keeps track of any properties unknown to the library. + internal TrustedSigningAccountSku(TrustedSigningSkuName name, IDictionary serializedAdditionalRawData) + { + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TrustedSigningAccountSku() + { + } + + /// Name of the SKU. + public TrustedSigningSkuName Name { get; set; } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningCertificate.Serialization.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningCertificate.Serialization.cs new file mode 100644 index 0000000000000..84c56f6b5c091 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningCertificate.Serialization.cs @@ -0,0 +1,295 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + public partial class TrustedSigningCertificate : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningCertificate)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(SerialNumber)) + { + writer.WritePropertyName("serialNumber"u8); + writer.WriteStringValue(SerialNumber); + } + if (Optional.IsDefined(SubjectName)) + { + writer.WritePropertyName("subjectName"u8); + writer.WriteStringValue(SubjectName); + } + if (Optional.IsDefined(Thumbprint)) + { + writer.WritePropertyName("thumbprint"u8); + writer.WriteStringValue(Thumbprint); + } + if (Optional.IsDefined(CreateOn)) + { + writer.WritePropertyName("createdDate"u8); + writer.WriteStringValue(CreateOn.Value, "O"); + } + if (Optional.IsDefined(ExpireOn)) + { + writer.WritePropertyName("expiryDate"u8); + writer.WriteStringValue(ExpireOn.Value, "O"); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + writer.WritePropertyName("revocation"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(RequestedOn)) + { + writer.WritePropertyName("requestedAt"u8); + writer.WriteStringValue(RequestedOn.Value, "O"); + } + if (Optional.IsDefined(EffectiveOn)) + { + writer.WritePropertyName("effectiveAt"u8); + writer.WriteStringValue(EffectiveOn.Value, "O"); + } + if (Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason); + } + if (Optional.IsDefined(Remarks)) + { + writer.WritePropertyName("remarks"u8); + writer.WriteStringValue(Remarks); + } + if (options.Format != "W" && Optional.IsDefined(StatusRevocationStatus)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(StatusRevocationStatus.Value.ToString()); + } + if (Optional.IsDefined(FailureReason)) + { + writer.WritePropertyName("failureReason"u8); + writer.WriteStringValue(FailureReason); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TrustedSigningCertificate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningCertificate)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrustedSigningCertificate(document.RootElement, options); + } + + internal static TrustedSigningCertificate DeserializeTrustedSigningCertificate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string serialNumber = default; + string subjectName = default; + string thumbprint = default; + DateTimeOffset? createdDate = default; + DateTimeOffset? expiryDate = default; + TrustedSigningCertificateStatus? status = default; + DateTimeOffset? requestedAt = default; + DateTimeOffset? effectiveAt = default; + string reason = default; + string remarks = default; + CertificateRevocationStatus? status0 = default; + string failureReason = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("serialNumber"u8)) + { + serialNumber = property.Value.GetString(); + continue; + } + if (property.NameEquals("subjectName"u8)) + { + subjectName = property.Value.GetString(); + continue; + } + if (property.NameEquals("thumbprint"u8)) + { + thumbprint = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDate = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("expiryDate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expiryDate = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new TrustedSigningCertificateStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("revocation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("requestedAt"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + requestedAt = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("effectiveAt"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + effectiveAt = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("reason"u8)) + { + reason = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("remarks"u8)) + { + remarks = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("status"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status0 = new CertificateRevocationStatus(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("failureReason"u8)) + { + failureReason = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TrustedSigningCertificate( + serialNumber, + subjectName, + thumbprint, + createdDate, + expiryDate, + status, + requestedAt, + effectiveAt, + reason, + remarks, + status0, + failureReason, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TrustedSigningCertificate)} does not support writing '{options.Format}' format."); + } + } + + TrustedSigningCertificate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTrustedSigningCertificate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrustedSigningCertificate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningCertificate.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningCertificate.cs new file mode 100644 index 0000000000000..3f74297a0f43e --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningCertificate.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + /// Properties of the certificate. + public partial class TrustedSigningCertificate + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal TrustedSigningCertificate() + { + } + + /// Initializes a new instance of . + /// Serial number of the certificate. + /// Subject name of the certificate. + /// Thumbprint of the certificate. + /// Certificate created date. + /// Certificate expiry date. + /// Status of the certificate. + /// The timestamp when the revocation is requested. + /// The timestamp when the revocation is effective. + /// Reason for revocation. + /// Remarks for the revocation. + /// Status of the revocation. + /// Reason for the revocation failure. + /// Keeps track of any properties unknown to the library. + internal TrustedSigningCertificate(string serialNumber, string subjectName, string thumbprint, DateTimeOffset? createOn, DateTimeOffset? expireOn, TrustedSigningCertificateStatus? status, DateTimeOffset? requestedOn, DateTimeOffset? effectiveOn, string reason, string remarks, CertificateRevocationStatus? statusRevocationStatus, string failureReason, IDictionary serializedAdditionalRawData) + { + SerialNumber = serialNumber; + SubjectName = subjectName; + Thumbprint = thumbprint; + CreateOn = createOn; + ExpireOn = expireOn; + Status = status; + RequestedOn = requestedOn; + EffectiveOn = effectiveOn; + Reason = reason; + Remarks = remarks; + StatusRevocationStatus = statusRevocationStatus; + FailureReason = failureReason; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Serial number of the certificate. + public string SerialNumber { get; } + /// Subject name of the certificate. + public string SubjectName { get; } + /// Thumbprint of the certificate. + public string Thumbprint { get; } + /// Certificate created date. + public DateTimeOffset? CreateOn { get; } + /// Certificate expiry date. + public DateTimeOffset? ExpireOn { get; } + /// Status of the certificate. + public TrustedSigningCertificateStatus? Status { get; } + /// The timestamp when the revocation is requested. + public DateTimeOffset? RequestedOn { get; } + /// The timestamp when the revocation is effective. + public DateTimeOffset? EffectiveOn { get; } + /// Reason for revocation. + public string Reason { get; } + /// Remarks for the revocation. + public string Remarks { get; } + /// Status of the revocation. + public CertificateRevocationStatus? StatusRevocationStatus { get; } + /// Reason for the revocation failure. + public string FailureReason { get; } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningCertificateStatus.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningCertificateStatus.cs new file mode 100644 index 0000000000000..eaf2346289f8a --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningCertificateStatus.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.TrustedSigning.Models +{ + /// Status of the certificate. + public readonly partial struct TrustedSigningCertificateStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TrustedSigningCertificateStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ActiveValue = "Active"; + private const string ExpiredValue = "Expired"; + private const string RevokedValue = "Revoked"; + + /// The certificate is active. + public static TrustedSigningCertificateStatus Active { get; } = new TrustedSigningCertificateStatus(ActiveValue); + /// The certificate is expired. + public static TrustedSigningCertificateStatus Expired { get; } = new TrustedSigningCertificateStatus(ExpiredValue); + /// The certificate is revoked. + public static TrustedSigningCertificateStatus Revoked { get; } = new TrustedSigningCertificateStatus(RevokedValue); + /// Determines if two values are the same. + public static bool operator ==(TrustedSigningCertificateStatus left, TrustedSigningCertificateStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TrustedSigningCertificateStatus left, TrustedSigningCertificateStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator TrustedSigningCertificateStatus(string value) => new TrustedSigningCertificateStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TrustedSigningCertificateStatus other && Equals(other); + /// + public bool Equals(TrustedSigningCertificateStatus 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningProvisioningState.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningProvisioningState.cs new file mode 100644 index 0000000000000..3b0506d76daad --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningProvisioningState.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.TrustedSigning.Models +{ + /// The status of the current operation. + public readonly partial struct TrustedSigningProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TrustedSigningProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + private const string UpdatingValue = "Updating"; + private const string DeletingValue = "Deleting"; + private const string AcceptedValue = "Accepted"; + + /// Resource has been created. + public static TrustedSigningProvisioningState Succeeded { get; } = new TrustedSigningProvisioningState(SucceededValue); + /// Resource creation failed. + public static TrustedSigningProvisioningState Failed { get; } = new TrustedSigningProvisioningState(FailedValue); + /// Resource creation was canceled. + public static TrustedSigningProvisioningState Canceled { get; } = new TrustedSigningProvisioningState(CanceledValue); + /// Updating in progress. + public static TrustedSigningProvisioningState Updating { get; } = new TrustedSigningProvisioningState(UpdatingValue); + /// Deletion in progress. + public static TrustedSigningProvisioningState Deleting { get; } = new TrustedSigningProvisioningState(DeletingValue); + /// Resource creation started. + public static TrustedSigningProvisioningState Accepted { get; } = new TrustedSigningProvisioningState(AcceptedValue); + /// Determines if two values are the same. + public static bool operator ==(TrustedSigningProvisioningState left, TrustedSigningProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TrustedSigningProvisioningState left, TrustedSigningProvisioningState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator TrustedSigningProvisioningState(string value) => new TrustedSigningProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TrustedSigningProvisioningState other && Equals(other); + /// + public bool Equals(TrustedSigningProvisioningState 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningSkuName.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningSkuName.cs new file mode 100644 index 0000000000000..56f7278edd347 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/Models/TrustedSigningSkuName.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.TrustedSigning.Models +{ + /// Name of the sku. + public readonly partial struct TrustedSigningSkuName : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TrustedSigningSkuName(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string BasicValue = "Basic"; + private const string PremiumValue = "Premium"; + + /// Basic sku. + public static TrustedSigningSkuName Basic { get; } = new TrustedSigningSkuName(BasicValue); + /// Premium sku. + public static TrustedSigningSkuName Premium { get; } = new TrustedSigningSkuName(PremiumValue); + /// Determines if two values are the same. + public static bool operator ==(TrustedSigningSkuName left, TrustedSigningSkuName right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TrustedSigningSkuName left, TrustedSigningSkuName right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator TrustedSigningSkuName(string value) => new TrustedSigningSkuName(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TrustedSigningSkuName other && Equals(other); + /// + public bool Equals(TrustedSigningSkuName 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/ProviderConstants.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/ProviderConstants.cs new file mode 100644 index 0000000000000..3a43bd648a3ef --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/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.TrustedSigning +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/RestOperations/CertificateProfilesRestOperations.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/RestOperations/CertificateProfilesRestOperations.cs new file mode 100644 index 0000000000000..5707061c940bc --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/RestOperations/CertificateProfilesRestOperations.cs @@ -0,0 +1,526 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning +{ + internal partial class CertificateProfilesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of CertificateProfilesRestOperations. + /// 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 CertificateProfilesRestOperations(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 ?? "2024-02-05-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListByCodeSigningAccountRequest(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CodeSigning/codeSigningAccounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/certificateProfiles", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List certificate profiles under a trusted signing account. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCodeSigningAccountAsync(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListByCodeSigningAccountRequest(subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CertificateProfileListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CertificateProfileListResult.DeserializeCertificateProfileListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List certificate profiles under a trusted signing account. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCodeSigningAccount(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListByCodeSigningAccountRequest(subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CertificateProfileListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CertificateProfileListResult.DeserializeCertificateProfileListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string accountName, string profileName) + { + 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.CodeSigning/codeSigningAccounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/certificateProfiles/", false); + uri.AppendPath(profileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get details of a certificate profile. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Certificate profile name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string accountName, string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, profileName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TrustedSigningCertificateProfileData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = TrustedSigningCertificateProfileData.DeserializeTrustedSigningCertificateProfileData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((TrustedSigningCertificateProfileData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get details of a certificate profile. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Certificate profile name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string accountName, string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, profileName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TrustedSigningCertificateProfileData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = TrustedSigningCertificateProfileData.DeserializeTrustedSigningCertificateProfileData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((TrustedSigningCertificateProfileData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string accountName, string profileName, TrustedSigningCertificateProfileData 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.CodeSigning/codeSigningAccounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/certificateProfiles/", false); + uri.AppendPath(profileName, 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, new ModelReaderWriterOptions("W")); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a certificate profile. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Certificate profile name. + /// Parameters to create the certificate profile. + /// 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 accountName, string profileName, TrustedSigningCertificateProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, accountName, profileName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a certificate profile. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Certificate profile name. + /// Parameters to create the certificate profile. + /// 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 accountName, string profileName, TrustedSigningCertificateProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, accountName, profileName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string accountName, string profileName) + { + 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.CodeSigning/codeSigningAccounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/certificateProfiles/", false); + uri.AppendPath(profileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a certificate profile. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Certificate profile name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string accountName, string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName, profileName); + 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 a certificate profile. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Certificate profile name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string accountName, string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName, profileName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateRevokeCertificateRequest(string subscriptionId, string resourceGroupName, string accountName, string profileName, RevokeCertificateContent content) + { + 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("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.CodeSigning/codeSigningAccounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/certificateProfiles/", false); + uri.AppendPath(profileName, true); + uri.AppendPath("/revokeCertificate", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, new ModelReaderWriterOptions("W")); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Revoke a certificate under a certificate profile. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Certificate profile name. + /// Parameters to revoke the certificate profile. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task RevokeCertificateAsync(string subscriptionId, string resourceGroupName, string accountName, string profileName, RevokeCertificateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateRevokeCertificateRequest(subscriptionId, resourceGroupName, accountName, profileName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Revoke a certificate under a certificate profile. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Certificate profile name. + /// Parameters to revoke the certificate profile. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response RevokeCertificate(string subscriptionId, string resourceGroupName, string accountName, string profileName, RevokeCertificateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateRevokeCertificateRequest(subscriptionId, resourceGroupName, accountName, profileName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByCodeSigningAccountNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string accountName) + { + 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; + } + + /// List certificate profiles under a trusted signing account. + /// 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. + /// Trusted Signing account name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCodeSigningAccountNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListByCodeSigningAccountNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CertificateProfileListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CertificateProfileListResult.DeserializeCertificateProfileListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List certificate profiles under a trusted signing account. + /// 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. + /// Trusted Signing account name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCodeSigningAccountNextPage(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListByCodeSigningAccountNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CertificateProfileListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CertificateProfileListResult.DeserializeCertificateProfileListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/RestOperations/CodeSigningAccountsRestOperations.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/RestOperations/CodeSigningAccountsRestOperations.cs new file mode 100644 index 0000000000000..893f7f4417705 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/RestOperations/CodeSigningAccountsRestOperations.cs @@ -0,0 +1,703 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning +{ + internal partial class CodeSigningAccountsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of CodeSigningAccountsRestOperations. + /// 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 CodeSigningAccountsRestOperations(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 ?? "2024-02-05-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateCheckNameAvailabilityRequest(string subscriptionId, TrustedSigningAccountNameAvailabilityContent content) + { + 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.CodeSigning/checkNameAvailability", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, new ModelReaderWriterOptions("W")); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Checks that the trusted signing account name is valid and is not already in use. + /// The ID of the target subscription. The value must be an UUID. + /// The CheckAvailability request. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> CheckNameAvailabilityAsync(string subscriptionId, TrustedSigningAccountNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCheckNameAvailabilityRequest(subscriptionId, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TrustedSigningAccountNameAvailabilityResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = TrustedSigningAccountNameAvailabilityResult.DeserializeTrustedSigningAccountNameAvailabilityResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Checks that the trusted signing account name is valid and is not already in use. + /// The ID of the target subscription. The value must be an UUID. + /// The CheckAvailability request. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response CheckNameAvailability(string subscriptionId, TrustedSigningAccountNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCheckNameAvailabilityRequest(subscriptionId, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TrustedSigningAccountNameAvailabilityResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = TrustedSigningAccountNameAvailabilityResult.DeserializeTrustedSigningAccountNameAvailabilityResult(document.RootElement); + return Response.FromValue(value, 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.CodeSigning/codeSigningAccounts", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists trusted signing accounts within a 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: + { + CodeSigningAccountListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CodeSigningAccountListResult.DeserializeCodeSigningAccountListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists trusted signing accounts within a 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: + { + CodeSigningAccountListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CodeSigningAccountListResult.DeserializeCodeSigningAccountListResult(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.CodeSigning/codeSigningAccounts", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists trusted signing accounts within a 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: + { + CodeSigningAccountListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CodeSigningAccountListResult.DeserializeCodeSigningAccountListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists trusted signing accounts within a 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: + { + CodeSigningAccountListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CodeSigningAccountListResult.DeserializeCodeSigningAccountListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CodeSigning/codeSigningAccounts/", false); + uri.AppendPath(accountName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a trusted Signing Account. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TrustedSigningAccountData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = TrustedSigningAccountData.DeserializeTrustedSigningAccountData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((TrustedSigningAccountData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a trusted Signing Account. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TrustedSigningAccountData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = TrustedSigningAccountData.DeserializeTrustedSigningAccountData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((TrustedSigningAccountData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string accountName, TrustedSigningAccountData 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.CodeSigning/codeSigningAccounts/", false); + uri.AppendPath(accountName, 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, new ModelReaderWriterOptions("W")); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a trusted Signing Account. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Parameters to create the trusted signing account. + /// 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 accountName, TrustedSigningAccountData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, accountName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a trusted Signing Account. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Parameters to create the trusted signing account. + /// 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 accountName, TrustedSigningAccountData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, accountName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string accountName, TrustedSigningAccountPatch 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.CodeSigning/codeSigningAccounts/", false); + uri.AppendPath(accountName, 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, new ModelReaderWriterOptions("W")); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a trusted signing account. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Parameters supplied to update the trusted signing account. + /// 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 accountName, TrustedSigningAccountPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, accountName, 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 a trusted signing account. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// Parameters supplied to update the trusted signing account. + /// 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 accountName, TrustedSigningAccountPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, accountName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CodeSigning/codeSigningAccounts/", false); + uri.AppendPath(accountName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a trusted signing account. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName); + 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 a trusted signing account. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Trusted Signing account name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return 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 trusted signing accounts within a 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: + { + CodeSigningAccountListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CodeSigningAccountListResult.DeserializeCodeSigningAccountListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists trusted signing accounts within a 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: + { + CodeSigningAccountListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CodeSigningAccountListResult.DeserializeCodeSigningAccountListResult(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 trusted signing accounts within a 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: + { + CodeSigningAccountListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CodeSigningAccountListResult.DeserializeCodeSigningAccountListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists trusted signing accounts within a 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: + { + CodeSigningAccountListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CodeSigningAccountListResult.DeserializeCodeSigningAccountListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountCollection.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountCollection.cs new file mode 100644 index 0000000000000..8dae5879ef085 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountCollection.cs @@ -0,0 +1,494 @@ +// 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.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.TrustedSigning +{ + /// + /// 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 GetTrustedSigningAccounts method from an instance of . + /// + public partial class TrustedSigningAccountCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _trustedSigningAccountCodeSigningAccountsClientDiagnostics; + private readonly CodeSigningAccountsRestOperations _trustedSigningAccountCodeSigningAccountsRestClient; + + /// Initializes a new instance of the class for mocking. + protected TrustedSigningAccountCollection() + { + } + + /// 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 TrustedSigningAccountCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _trustedSigningAccountCodeSigningAccountsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrustedSigning", TrustedSigningAccountResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(TrustedSigningAccountResource.ResourceType, out string trustedSigningAccountCodeSigningAccountsApiVersion); + _trustedSigningAccountCodeSigningAccountsRestClient = new CodeSigningAccountsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trustedSigningAccountCodeSigningAccountsApiVersion); +#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)); + } + + /// + /// Create a trusted Signing Account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Create + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// Trusted Signing account name. + /// Parameters to create the trusted signing account. + /// 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 accountName, TrustedSigningAccountData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _trustedSigningAccountCodeSigningAccountsRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, accountName, data, cancellationToken).ConfigureAwait(false); + var operation = new TrustedSigningArmOperation(new TrustedSigningAccountOperationSource(Client), _trustedSigningAccountCodeSigningAccountsClientDiagnostics, Pipeline, _trustedSigningAccountCodeSigningAccountsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, accountName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a trusted Signing Account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Create + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// Trusted Signing account name. + /// Parameters to create the trusted signing account. + /// 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 accountName, TrustedSigningAccountData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _trustedSigningAccountCodeSigningAccountsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, accountName, data, cancellationToken); + var operation = new TrustedSigningArmOperation(new TrustedSigningAccountOperationSource(Client), _trustedSigningAccountCodeSigningAccountsClientDiagnostics, Pipeline, _trustedSigningAccountCodeSigningAccountsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, accountName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a trusted Signing Account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Trusted Signing account name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountCollection.Get"); + scope.Start(); + try + { + var response = await _trustedSigningAccountCodeSigningAccountsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, accountName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningAccountResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a trusted Signing Account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Trusted Signing account name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountCollection.Get"); + scope.Start(); + try + { + var response = _trustedSigningAccountCodeSigningAccountsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, accountName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningAccountResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists trusted signing accounts within a resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts + /// + /// + /// Operation Id + /// CodeSigningAccounts_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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) => _trustedSigningAccountCodeSigningAccountsRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _trustedSigningAccountCodeSigningAccountsRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new TrustedSigningAccountResource(Client, TrustedSigningAccountData.DeserializeTrustedSigningAccountData(e)), _trustedSigningAccountCodeSigningAccountsClientDiagnostics, Pipeline, "TrustedSigningAccountCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists trusted signing accounts within a resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts + /// + /// + /// Operation Id + /// CodeSigningAccounts_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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) => _trustedSigningAccountCodeSigningAccountsRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _trustedSigningAccountCodeSigningAccountsRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TrustedSigningAccountResource(Client, TrustedSigningAccountData.DeserializeTrustedSigningAccountData(e)), _trustedSigningAccountCodeSigningAccountsClientDiagnostics, Pipeline, "TrustedSigningAccountCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Trusted Signing account name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountCollection.Exists"); + scope.Start(); + try + { + var response = await _trustedSigningAccountCodeSigningAccountsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, accountName, 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.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Trusted Signing account name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountCollection.Exists"); + scope.Start(); + try + { + var response = _trustedSigningAccountCodeSigningAccountsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, accountName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Trusted Signing account name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _trustedSigningAccountCodeSigningAccountsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, accountName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningAccountResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Trusted Signing account name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountCollection.GetIfExists"); + scope.Start(); + try + { + var response = _trustedSigningAccountCodeSigningAccountsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, accountName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningAccountResource(Client, response.Value), 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountData.Serialization.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountData.Serialization.cs new file mode 100644 index 0000000000000..d6d440aacc923 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountData.Serialization.cs @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning +{ + public partial class TrustedSigningAccountData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningAccountData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(AccountUri)) + { + writer.WritePropertyName("accountUri"u8); + writer.WriteStringValue(AccountUri.AbsoluteUri); + } + if (Optional.IsDefined(Sku)) + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TrustedSigningAccountData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningAccountData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrustedSigningAccountData(document.RootElement, options); + } + + internal static TrustedSigningAccountData DeserializeTrustedSigningAccountData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + Uri accountUri = default; + TrustedSigningAccountSku sku = default; + TrustedSigningProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + 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("accountUri"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + accountUri = new Uri(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("sku"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sku = TrustedSigningAccountSku.DeserializeTrustedSigningAccountSku(property0.Value, options); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new TrustedSigningProvisioningState(property0.Value.GetString()); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TrustedSigningAccountData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + accountUri, + sku, + provisioningState, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TrustedSigningAccountData)} does not support writing '{options.Format}' format."); + } + } + + TrustedSigningAccountData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTrustedSigningAccountData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrustedSigningAccountData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountData.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountData.cs new file mode 100644 index 0000000000000..e83d4761ddada --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountData.cs @@ -0,0 +1,101 @@ +// 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.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning +{ + /// + /// A class representing the TrustedSigningAccount data model. + /// Trusted signing account resource. + /// + public partial class TrustedSigningAccountData : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + public TrustedSigningAccountData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The URI of the trusted signing account which is used during signing files. + /// SKU of the trusted signing account. + /// Status of the current operation on trusted signing account. + /// Keeps track of any properties unknown to the library. + internal TrustedSigningAccountData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, Uri accountUri, TrustedSigningAccountSku sku, TrustedSigningProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + AccountUri = accountUri; + Sku = sku; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TrustedSigningAccountData() + { + } + + /// The URI of the trusted signing account which is used during signing files. + public Uri AccountUri { get; } + /// SKU of the trusted signing account. + internal TrustedSigningAccountSku Sku { get; set; } + /// Name of the SKU. + public TrustedSigningSkuName? SkuName + { + get => Sku is null ? default(TrustedSigningSkuName?) : Sku.Name; + set + { + Sku = value.HasValue ? new TrustedSigningAccountSku(value.Value) : null; + } + } + + /// Status of the current operation on trusted signing account. + public TrustedSigningProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountResource.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountResource.cs new file mode 100644 index 0000000000000..e4e1053e4c0b1 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningAccountResource.cs @@ -0,0 +1,776 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning +{ + /// + /// A Class representing a TrustedSigningAccount 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 GetTrustedSigningAccountResource method. + /// Otherwise you can get one from its parent resource using the GetTrustedSigningAccount method. + /// + public partial class TrustedSigningAccountResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The accountName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string accountName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _trustedSigningAccountCodeSigningAccountsClientDiagnostics; + private readonly CodeSigningAccountsRestOperations _trustedSigningAccountCodeSigningAccountsRestClient; + private readonly TrustedSigningAccountData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.CodeSigning/codeSigningAccounts"; + + /// Initializes a new instance of the class for mocking. + protected TrustedSigningAccountResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal TrustedSigningAccountResource(ArmClient client, TrustedSigningAccountData 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 TrustedSigningAccountResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _trustedSigningAccountCodeSigningAccountsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrustedSigning", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string trustedSigningAccountCodeSigningAccountsApiVersion); + _trustedSigningAccountCodeSigningAccountsRestClient = new CodeSigningAccountsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trustedSigningAccountCodeSigningAccountsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 TrustedSigningAccountData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// Gets a collection of TrustedSigningCertificateProfileResources in the TrustedSigningAccount. + /// An object representing collection of TrustedSigningCertificateProfileResources and their operations over a TrustedSigningCertificateProfileResource. + public virtual TrustedSigningCertificateProfileCollection GetTrustedSigningCertificateProfiles() + { + return GetCachedClient(client => new TrustedSigningCertificateProfileCollection(client, Id)); + } + + /// + /// Get details of a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Certificate profile name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTrustedSigningCertificateProfileAsync(string profileName, CancellationToken cancellationToken = default) + { + return await GetTrustedSigningCertificateProfiles().GetAsync(profileName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get details of a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Certificate profile name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTrustedSigningCertificateProfile(string profileName, CancellationToken cancellationToken = default) + { + return GetTrustedSigningCertificateProfiles().Get(profileName, cancellationToken); + } + + /// + /// Get a trusted Signing Account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.Get"); + scope.Start(); + try + { + var response = await _trustedSigningAccountCodeSigningAccountsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningAccountResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a trusted Signing Account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.Get"); + scope.Start(); + try + { + var response = _trustedSigningAccountCodeSigningAccountsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningAccountResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a trusted signing account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Delete + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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 = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.Delete"); + scope.Start(); + try + { + var response = await _trustedSigningAccountCodeSigningAccountsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new TrustedSigningArmOperation(_trustedSigningAccountCodeSigningAccountsClientDiagnostics, Pipeline, _trustedSigningAccountCodeSigningAccountsRestClient.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 a trusted signing account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Delete + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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 = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.Delete"); + scope.Start(); + try + { + var response = _trustedSigningAccountCodeSigningAccountsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new TrustedSigningArmOperation(_trustedSigningAccountCodeSigningAccountsClientDiagnostics, Pipeline, _trustedSigningAccountCodeSigningAccountsRestClient.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 a trusted signing account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Update + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// Parameters supplied to update the trusted signing account. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, TrustedSigningAccountPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.Update"); + scope.Start(); + try + { + var response = await _trustedSigningAccountCodeSigningAccountsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new TrustedSigningArmOperation(new TrustedSigningAccountOperationSource(Client), _trustedSigningAccountCodeSigningAccountsClientDiagnostics, Pipeline, _trustedSigningAccountCodeSigningAccountsRestClient.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 a trusted signing account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Update + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// Parameters supplied to update the trusted signing account. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, TrustedSigningAccountPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.Update"); + scope.Start(); + try + { + var response = _trustedSigningAccountCodeSigningAccountsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + var operation = new TrustedSigningArmOperation(new TrustedSigningAccountOperationSource(Client), _trustedSigningAccountCodeSigningAccountsClientDiagnostics, Pipeline, _trustedSigningAccountCodeSigningAccountsRestClient.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; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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 = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.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 _trustedSigningAccountCodeSigningAccountsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new TrustedSigningAccountResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new TrustedSigningAccountPatch(); + 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.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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 = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.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 = _trustedSigningAccountCodeSigningAccountsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new TrustedSigningAccountResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new TrustedSigningAccountPatch(); + 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.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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 = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.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 _trustedSigningAccountCodeSigningAccountsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new TrustedSigningAccountResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new TrustedSigningAccountPatch(); + 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.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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 = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.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 = _trustedSigningAccountCodeSigningAccountsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new TrustedSigningAccountResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new TrustedSigningAccountPatch(); + 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.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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 = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.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 _trustedSigningAccountCodeSigningAccountsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new TrustedSigningAccountResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new TrustedSigningAccountPatch(); + 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.CodeSigning/codeSigningAccounts/{accountName} + /// + /// + /// Operation Id + /// CodeSigningAccounts_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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 = _trustedSigningAccountCodeSigningAccountsClientDiagnostics.CreateScope("TrustedSigningAccountResource.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 = _trustedSigningAccountCodeSigningAccountsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new TrustedSigningAccountResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new TrustedSigningAccountPatch(); + 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileCollection.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileCollection.cs new file mode 100644 index 0000000000000..ee2ef7d017fa5 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileCollection.cs @@ -0,0 +1,493 @@ +// 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.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.TrustedSigning +{ + /// + /// 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 GetTrustedSigningCertificateProfiles method from an instance of . + /// + public partial class TrustedSigningCertificateProfileCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics; + private readonly CertificateProfilesRestOperations _trustedSigningCertificateProfileCertificateProfilesRestClient; + + /// Initializes a new instance of the class for mocking. + protected TrustedSigningCertificateProfileCollection() + { + } + + /// 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 TrustedSigningCertificateProfileCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrustedSigning", TrustedSigningCertificateProfileResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(TrustedSigningCertificateProfileResource.ResourceType, out string trustedSigningCertificateProfileCertificateProfilesApiVersion); + _trustedSigningCertificateProfileCertificateProfilesRestClient = new CertificateProfilesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trustedSigningCertificateProfileCertificateProfilesApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != TrustedSigningAccountResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, TrustedSigningAccountResource.ResourceType), nameof(id)); + } + + /// + /// Create a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Create + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// Certificate profile name. + /// Parameters to create the certificate profile. + /// 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 profileName, TrustedSigningCertificateProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, data, cancellationToken).ConfigureAwait(false); + var operation = new TrustedSigningArmOperation(new TrustedSigningCertificateProfileOperationSource(Client), _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics, Pipeline, _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Create + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// Certificate profile name. + /// Parameters to create the certificate profile. + /// 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 profileName, TrustedSigningCertificateProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _trustedSigningCertificateProfileCertificateProfilesRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, data, cancellationToken); + var operation = new TrustedSigningArmOperation(new TrustedSigningCertificateProfileOperationSource(Client), _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics, Pipeline, _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get details of a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Certificate profile name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileCollection.Get"); + scope.Start(); + try + { + var response = await _trustedSigningCertificateProfileCertificateProfilesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningCertificateProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get details of a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Certificate profile name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileCollection.Get"); + scope.Start(); + try + { + var response = _trustedSigningCertificateProfileCertificateProfilesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningCertificateProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List certificate profiles under a trusted signing account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles + /// + /// + /// Operation Id + /// CertificateProfiles_ListByCodeSigningAccount + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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) => _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateListByCodeSigningAccountRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateListByCodeSigningAccountNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new TrustedSigningCertificateProfileResource(Client, TrustedSigningCertificateProfileData.DeserializeTrustedSigningCertificateProfileData(e)), _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics, Pipeline, "TrustedSigningCertificateProfileCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List certificate profiles under a trusted signing account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles + /// + /// + /// Operation Id + /// CertificateProfiles_ListByCodeSigningAccount + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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) => _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateListByCodeSigningAccountRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateListByCodeSigningAccountNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TrustedSigningCertificateProfileResource(Client, TrustedSigningCertificateProfileData.DeserializeTrustedSigningCertificateProfileData(e)), _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics, Pipeline, "TrustedSigningCertificateProfileCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Certificate profile name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileCollection.Exists"); + scope.Start(); + try + { + var response = await _trustedSigningCertificateProfileCertificateProfilesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, 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.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Certificate profile name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileCollection.Exists"); + scope.Start(); + try + { + var response = _trustedSigningCertificateProfileCertificateProfilesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Certificate profile name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _trustedSigningCertificateProfileCertificateProfilesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningCertificateProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Certificate profile name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileCollection.GetIfExists"); + scope.Start(); + try + { + var response = _trustedSigningCertificateProfileCertificateProfilesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningCertificateProfileResource(Client, response.Value), 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/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileData.Serialization.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileData.Serialization.cs new file mode 100644 index 0000000000000..5e29221a45e0c --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileData.Serialization.cs @@ -0,0 +1,455 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning +{ + public partial class TrustedSigningCertificateProfileData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningCertificateProfileData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(ProfileType)) + { + writer.WritePropertyName("profileType"u8); + writer.WriteStringValue(ProfileType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(CommonName)) + { + writer.WritePropertyName("commonName"u8); + writer.WriteStringValue(CommonName); + } + if (options.Format != "W" && Optional.IsDefined(Organization)) + { + writer.WritePropertyName("organization"u8); + writer.WriteStringValue(Organization); + } + if (options.Format != "W" && Optional.IsDefined(OrganizationUnit)) + { + writer.WritePropertyName("organizationUnit"u8); + writer.WriteStringValue(OrganizationUnit); + } + if (options.Format != "W" && Optional.IsDefined(StreetAddress)) + { + writer.WritePropertyName("streetAddress"u8); + writer.WriteStringValue(StreetAddress); + } + if (Optional.IsDefined(IncludeStreetAddress)) + { + writer.WritePropertyName("includeStreetAddress"u8); + writer.WriteBooleanValue(IncludeStreetAddress.Value); + } + if (options.Format != "W" && Optional.IsDefined(City)) + { + writer.WritePropertyName("city"u8); + writer.WriteStringValue(City); + } + if (Optional.IsDefined(IncludeCity)) + { + writer.WritePropertyName("includeCity"u8); + writer.WriteBooleanValue(IncludeCity.Value); + } + if (options.Format != "W" && Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State); + } + if (Optional.IsDefined(IncludeState)) + { + writer.WritePropertyName("includeState"u8); + writer.WriteBooleanValue(IncludeState.Value); + } + if (options.Format != "W" && Optional.IsDefined(Country)) + { + writer.WritePropertyName("country"u8); + writer.WriteStringValue(Country); + } + if (Optional.IsDefined(IncludeCountry)) + { + writer.WritePropertyName("includeCountry"u8); + writer.WriteBooleanValue(IncludeCountry.Value); + } + if (options.Format != "W" && Optional.IsDefined(PostalCode)) + { + writer.WritePropertyName("postalCode"u8); + writer.WriteStringValue(PostalCode); + } + if (Optional.IsDefined(IncludePostalCode)) + { + writer.WritePropertyName("includePostalCode"u8); + writer.WriteBooleanValue(IncludePostalCode.Value); + } + if (options.Format != "W" && Optional.IsDefined(EnhancedKeyUsage)) + { + writer.WritePropertyName("enhancedKeyUsage"u8); + writer.WriteStringValue(EnhancedKeyUsage); + } + if (Optional.IsDefined(IdentityValidationId)) + { + writer.WritePropertyName("identityValidationId"u8); + writer.WriteStringValue(IdentityValidationId); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Certificates)) + { + writer.WritePropertyName("certificates"u8); + writer.WriteStartArray(); + foreach (var item in Certificates) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TrustedSigningCertificateProfileData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrustedSigningCertificateProfileData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrustedSigningCertificateProfileData(document.RootElement, options); + } + + internal static TrustedSigningCertificateProfileData DeserializeTrustedSigningCertificateProfileData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + CertificateProfileType? profileType = default; + string commonName = default; + string organization = default; + string organizationUnit = default; + string streetAddress = default; + bool? includeStreetAddress = default; + string city = default; + bool? includeCity = default; + string state = default; + bool? includeState = default; + string country = default; + bool? includeCountry = default; + string postalCode = default; + bool? includePostalCode = default; + string enhancedKeyUsage = default; + string identityValidationId = default; + TrustedSigningProvisioningState? provisioningState = default; + CertificateProfileStatus? status = default; + IReadOnlyList certificates = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + 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("profileType"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + profileType = new CertificateProfileType(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("commonName"u8)) + { + commonName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("organization"u8)) + { + organization = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("organizationUnit"u8)) + { + organizationUnit = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("streetAddress"u8)) + { + streetAddress = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("includeStreetAddress"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + includeStreetAddress = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("city"u8)) + { + city = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("includeCity"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + includeCity = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("state"u8)) + { + state = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("includeState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + includeState = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("country"u8)) + { + country = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("includeCountry"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + includeCountry = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("postalCode"u8)) + { + postalCode = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("includePostalCode"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + includePostalCode = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("enhancedKeyUsage"u8)) + { + enhancedKeyUsage = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("identityValidationId"u8)) + { + identityValidationId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new TrustedSigningProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("status"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new CertificateProfileStatus(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("certificates"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(TrustedSigningCertificate.DeserializeTrustedSigningCertificate(item, options)); + } + certificates = array; + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TrustedSigningCertificateProfileData( + id, + name, + type, + systemData, + profileType, + commonName, + organization, + organizationUnit, + streetAddress, + includeStreetAddress, + city, + includeCity, + state, + includeState, + country, + includeCountry, + postalCode, + includePostalCode, + enhancedKeyUsage, + identityValidationId, + provisioningState, + status, + certificates ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TrustedSigningCertificateProfileData)} does not support writing '{options.Format}' format."); + } + } + + TrustedSigningCertificateProfileData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTrustedSigningCertificateProfileData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrustedSigningCertificateProfileData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileData.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileData.cs new file mode 100644 index 0000000000000..234e6907664a8 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileData.cs @@ -0,0 +1,148 @@ +// 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.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning +{ + /// + /// A class representing the TrustedSigningCertificateProfile data model. + /// Certificate profile resource. + /// + public partial class TrustedSigningCertificateProfileData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TrustedSigningCertificateProfileData() + { + Certificates = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Profile type of the certificate. + /// Used as CN in the certificate subject name. + /// Used as O in the certificate subject name. + /// Used as OU in the private trust certificate subject name. + /// Used as STREET in the certificate subject name. + /// Whether to include STREET in the certificate subject name. + /// Used as L in the certificate subject name. + /// Whether to include L in the certificate subject name. Applicable only for private trust, private trust ci profile types. + /// Used as S in the certificate subject name. + /// Whether to include S in the certificate subject name. Applicable only for private trust, private trust ci profile types. + /// Used as C in the certificate subject name. + /// Whether to include C in the certificate subject name. Applicable only for private trust, private trust ci profile types. + /// Used as PC in the certificate subject name. + /// Whether to include PC in the certificate subject name. + /// Enhanced key usage of the certificate. + /// Identity validation id used for the certificate subject name. + /// Status of the current operation on certificate profile. + /// Status of the certificate profile. + /// List of renewed certificates. + /// Keeps track of any properties unknown to the library. + internal TrustedSigningCertificateProfileData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, CertificateProfileType? profileType, string commonName, string organization, string organizationUnit, string streetAddress, bool? includeStreetAddress, string city, bool? includeCity, string state, bool? includeState, string country, bool? includeCountry, string postalCode, bool? includePostalCode, string enhancedKeyUsage, string identityValidationId, TrustedSigningProvisioningState? provisioningState, CertificateProfileStatus? status, IReadOnlyList certificates, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + ProfileType = profileType; + CommonName = commonName; + Organization = organization; + OrganizationUnit = organizationUnit; + StreetAddress = streetAddress; + IncludeStreetAddress = includeStreetAddress; + City = city; + IncludeCity = includeCity; + State = state; + IncludeState = includeState; + Country = country; + IncludeCountry = includeCountry; + PostalCode = postalCode; + IncludePostalCode = includePostalCode; + EnhancedKeyUsage = enhancedKeyUsage; + IdentityValidationId = identityValidationId; + ProvisioningState = provisioningState; + Status = status; + Certificates = certificates; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Profile type of the certificate. + public CertificateProfileType? ProfileType { get; set; } + /// Used as CN in the certificate subject name. + public string CommonName { get; } + /// Used as O in the certificate subject name. + public string Organization { get; } + /// Used as OU in the private trust certificate subject name. + public string OrganizationUnit { get; } + /// Used as STREET in the certificate subject name. + public string StreetAddress { get; } + /// Whether to include STREET in the certificate subject name. + public bool? IncludeStreetAddress { get; set; } + /// Used as L in the certificate subject name. + public string City { get; } + /// Whether to include L in the certificate subject name. Applicable only for private trust, private trust ci profile types. + public bool? IncludeCity { get; set; } + /// Used as S in the certificate subject name. + public string State { get; } + /// Whether to include S in the certificate subject name. Applicable only for private trust, private trust ci profile types. + public bool? IncludeState { get; set; } + /// Used as C in the certificate subject name. + public string Country { get; } + /// Whether to include C in the certificate subject name. Applicable only for private trust, private trust ci profile types. + public bool? IncludeCountry { get; set; } + /// Used as PC in the certificate subject name. + public string PostalCode { get; } + /// Whether to include PC in the certificate subject name. + public bool? IncludePostalCode { get; set; } + /// Enhanced key usage of the certificate. + public string EnhancedKeyUsage { get; } + /// Identity validation id used for the certificate subject name. + public string IdentityValidationId { get; set; } + /// Status of the current operation on certificate profile. + public TrustedSigningProvisioningState? ProvisioningState { get; } + /// Status of the certificate profile. + public CertificateProfileStatus? Status { get; } + /// List of renewed certificates. + public IReadOnlyList Certificates { get; } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileResource.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileResource.cs new file mode 100644 index 0000000000000..8fc04f0a50c0d --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Generated/TrustedSigningCertificateProfileResource.cs @@ -0,0 +1,432 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.TrustedSigning.Models; + +namespace Azure.ResourceManager.TrustedSigning +{ + /// + /// A Class representing a TrustedSigningCertificateProfile 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 GetTrustedSigningCertificateProfileResource method. + /// Otherwise you can get one from its parent resource using the GetTrustedSigningCertificateProfile method. + /// + public partial class TrustedSigningCertificateProfileResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The accountName. + /// The profileName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string accountName, string profileName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics; + private readonly CertificateProfilesRestOperations _trustedSigningCertificateProfileCertificateProfilesRestClient; + private readonly TrustedSigningCertificateProfileData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.CodeSigning/codeSigningAccounts/certificateProfiles"; + + /// Initializes a new instance of the class for mocking. + protected TrustedSigningCertificateProfileResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal TrustedSigningCertificateProfileResource(ArmClient client, TrustedSigningCertificateProfileData 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 TrustedSigningCertificateProfileResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrustedSigning", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string trustedSigningCertificateProfileCertificateProfilesApiVersion); + _trustedSigningCertificateProfileCertificateProfilesRestClient = new CertificateProfilesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trustedSigningCertificateProfileCertificateProfilesApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 TrustedSigningCertificateProfileData 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 details of a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileResource.Get"); + scope.Start(); + try + { + var response = await _trustedSigningCertificateProfileCertificateProfilesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningCertificateProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get details of a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Get + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileResource.Get"); + scope.Start(); + try + { + var response = _trustedSigningCertificateProfileCertificateProfilesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TrustedSigningCertificateProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Delete + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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 = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileResource.Delete"); + scope.Start(); + try + { + var response = await _trustedSigningCertificateProfileCertificateProfilesRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new TrustedSigningArmOperation(_trustedSigningCertificateProfileCertificateProfilesClientDiagnostics, Pipeline, _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, 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 a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Delete + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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 = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileResource.Delete"); + scope.Start(); + try + { + var response = _trustedSigningCertificateProfileCertificateProfilesRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new TrustedSigningArmOperation(_trustedSigningCertificateProfileCertificateProfilesClientDiagnostics, Pipeline, _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Create + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// Parameters to create the certificate profile. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, TrustedSigningCertificateProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileResource.Update"); + scope.Start(); + try + { + var response = await _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new TrustedSigningArmOperation(new TrustedSigningCertificateProfileOperationSource(Client), _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics, Pipeline, _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName} + /// + /// + /// Operation Id + /// CertificateProfiles_Create + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// Parameters to create the certificate profile. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, TrustedSigningCertificateProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileResource.Update"); + scope.Start(); + try + { + var response = _trustedSigningCertificateProfileCertificateProfilesRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new TrustedSigningArmOperation(new TrustedSigningCertificateProfileOperationSource(Client), _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics, Pipeline, _trustedSigningCertificateProfileCertificateProfilesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Revoke a certificate under a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName}/revokeCertificate + /// + /// + /// Operation Id + /// CertificateProfiles_RevokeCertificate + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Parameters to revoke the certificate profile. + /// The cancellation token to use. + /// is null. + public virtual async Task RevokeCertificateAsync(RevokeCertificateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileResource.RevokeCertificate"); + scope.Start(); + try + { + var response = await _trustedSigningCertificateProfileCertificateProfilesRestClient.RevokeCertificateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Revoke a certificate under a certificate profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName}/revokeCertificate + /// + /// + /// Operation Id + /// CertificateProfiles_RevokeCertificate + /// + /// + /// Default Api Version + /// 2024-02-05-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Parameters to revoke the certificate profile. + /// The cancellation token to use. + /// is null. + public virtual Response RevokeCertificate(RevokeCertificateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _trustedSigningCertificateProfileCertificateProfilesClientDiagnostics.CreateScope("TrustedSigningCertificateProfileResource.RevokeCertificate"); + scope.Start(); + try + { + var response = _trustedSigningCertificateProfileCertificateProfilesRestClient.RevokeCertificate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Properties/AssemblyInfo.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000..593c1445d5aa3 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/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("Microsoft.CodeSigning")] + +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo("Azure.ResourceManager.TrustedSigning.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/autorest.md b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/autorest.md new file mode 100644 index 0000000000000..bb8a28ca4ca06 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/src/autorest.md @@ -0,0 +1,92 @@ +# Generated code configuration + +Run `dotnet build /t:GenerateCode` to generate code. + +``` yaml +azure-arm: true +csharp: true +library-name: TrustedSigning +namespace: Azure.ResourceManager.TrustedSigning +require: https://github.com/Azure/azure-rest-api-specs/blob/42e63ea88548151222ce3efa1bfce02d879fad6b/specification/codesigning/resource-manager/readme.md +#tag: package-2024-02-05-preview +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 +use-model-reader-writer: true + +#mgmt-debug: +# show-serialized-names: true + +rename-mapping: + CheckNameAvailability: TrustedSigningAccountNameAvailabilityContent + CheckNameAvailabilityResult: TrustedSigningAccountNameAvailabilityResult + CheckNameAvailabilityResult.nameAvailable: IsNameAvailable + NameUnavailabilityReason: TrustedSigningAccountNameUnavailabilityReason + Certificate.createdDate: CreateOn | datetime + Certificate.expiryDate: ExpireOn | datetime + CodeSigningAccount: TrustedSigningAccount + ProfileType: CertificateProfileType + ProfileType.VBSEnclave: VbsEnclave + RevocationStatus: CertificateRevocationStatus + RevokeCertificate: RevokeCertificateContent + +override-operation-name: + CodeSigningAccounts_CheckNameAvailability: CheckTrustedSigningAccountNameAvailability + +prepend-rp-prefix: + - AccountSku + - Certificate + - CertificateProfile + - CertificateStatus + - ProvisioningState + +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 + +directive: + # Fix the missing `type` property for CheckTrustedSigningAccountNameAvailability + - from: codeSigningAccount.json + where: $.definitions + transform: > + $.CheckNameAvailability.properties['type'] = { + 'type': 'string', + 'description': 'The type of the resource, \"Microsoft.CodeSigning/codeSigningAccounts\".', + 'x-ms-format': 'resource-type' + }; + $.CheckNameAvailability['required'] = [ + 'type', + 'name' + ]; +``` \ No newline at end of file diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/Azure.ResourceManager.TrustedSigning.Tests.csproj b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/Azure.ResourceManager.TrustedSigning.Tests.csproj new file mode 100644 index 0000000000000..589231717e468 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/Azure.ResourceManager.TrustedSigning.Tests.csproj @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/Scenario/TrustedSigningAccountTests.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/Scenario/TrustedSigningAccountTests.cs new file mode 100644 index 0000000000000..6178ce1b327ce --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/Scenario/TrustedSigningAccountTests.cs @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TrustedSigning.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.TrustedSigning.Tests.Scenario +{ + public class TrustedSigningAccountTests : TrustedSigningManagementTestBase + { + public TrustedSigningAccountTests(bool isAsync) : base(isAsync) + { + } + + public TrustedSigningAccountTests(bool isAsync, RecordedTestMode mode) : base(isAsync, mode) + { + } + + [Test] + [RecordedTest] + public async Task CheckNameAvailabilityCodeSigningAccount_ChecksThatTheTrustedSigningAccountNameIsAvailable() + { + string accountName = Recording.GenerateAssetName("account-"); + TrustedSigningAccountNameAvailabilityContent body = new TrustedSigningAccountNameAvailabilityContent(accountName, new ResourceType("Microsoft.CodeSigning/codeSigningAccounts")); + TrustedSigningAccountNameAvailabilityResult result = await DefaultSubscription.CheckTrustedSigningAccountNameAvailabilityAsync(body); + + Assert.IsTrue(result.IsNameAvailable); + } + + // Get a Trusted Signing Account + [Test] + [RecordedTest] + public async Task Get_GetATrustedSigningAccount() + { + TrustedSigningAccountCollection collection = await GetTrustedSigningAccounts(); + + string accountName = Recording.GenerateAssetName("account-"); + TrustedSigningAccountResource account = await CreateTrustedSigningAccount(collection, accountName); + Assert.IsNotNull(account); + + TrustedSigningAccountResource accountResource = Client.GetTrustedSigningAccountResource(account.Id); + TrustedSigningAccountResource result = await accountResource.GetAsync(); + Assert.IsNotNull(result); + Assert.AreEqual(result.Data.Name, accountName); + } + + // Update a trusted signing account. + [Test] + [RecordedTest] + public async Task Update_UpdateATrustedSigningAccount() + { + TrustedSigningAccountCollection collection = await GetTrustedSigningAccounts(); + + string accountName = Recording.GenerateAssetName("account-"); + TrustedSigningAccountResource account = await CreateTrustedSigningAccount(collection, accountName); + Assert.IsNotNull(account); + + // invoke the operation + TrustedSigningAccountPatch patch = new TrustedSigningAccountPatch() + { + Tags = { ["key1"] = "value1" } + }; + ArmOperation lro = await account.UpdateAsync(WaitUntil.Completed, patch); + TrustedSigningAccountResource result = lro.Value; + + TrustedSigningAccountData resourceData = result.Data; + Assert.IsNotNull(resourceData.Id); + Assert.AreEqual(resourceData.Tags["key1"], patch.Tags["key1"]); + } + + // Delete a trusted signing account. + [Test] + [RecordedTest] + public async Task Delete_DeleteATrustedSigningAccount() + { + TrustedSigningAccountCollection collection = await GetTrustedSigningAccounts(); + + string accountName = Recording.GenerateAssetName("account-"); + TrustedSigningAccountResource account = await CreateTrustedSigningAccount(collection, accountName); + Assert.IsNotNull(account); + + ArmOperation op = await account.DeleteAsync(WaitUntil.Completed); + Assert.IsTrue(op.HasCompleted); + } + + [Test] + [RecordedTest] + public async Task GetAll_ListsTrustedSigningAccountsWithinAResourceGroup() + { + TrustedSigningAccountCollection collection = await GetTrustedSigningAccounts(); + + string accountName = Recording.GenerateAssetName("account-"); + TrustedSigningAccountResource account = await CreateTrustedSigningAccount(collection, accountName); + Assert.IsNotNull(account); + + bool exist = false; + await foreach (TrustedSigningAccountResource item in collection.GetAllAsync()) + { + Assert.IsNotNull(item); + if (item.Id == account.Id) + { + exist = true; + break; + } + } + Assert.IsTrue(exist); + } + + [Test] + [RecordedTest] + public async Task Exists_GetATrustedSigningAccount() + { + TrustedSigningAccountCollection collection = await GetTrustedSigningAccounts(); + + string accountName = Recording.GenerateAssetName("account-"); + bool exist = await collection.ExistsAsync(accountName); + Assert.IsFalse(exist); + + TrustedSigningAccountResource account = await CreateTrustedSigningAccount(collection, accountName); + Assert.IsNotNull(account); + + exist = await collection.ExistsAsync(accountName); + Assert.IsTrue(exist); + } + + [Test] + [RecordedTest] + public async Task GetIfExists_GetATrustedSigningAccount() + { + TrustedSigningAccountCollection collection = await GetTrustedSigningAccounts(); + + string accountName = Recording.GenerateAssetName("account-"); + NullableResponse response = await collection.GetIfExistsAsync(accountName); + Assert.IsFalse(response.HasValue); + + TrustedSigningAccountResource account = await CreateTrustedSigningAccount(collection, accountName); + Assert.IsNotNull(account); + + response = await collection.GetIfExistsAsync(accountName); + Assert.IsTrue(response.HasValue); + Assert.IsNotNull(response.Value); + } + + [Test] + [RecordedTest] + public async Task CreateOrUpdate_CreateATrustedSigningAccount() + { + TrustedSigningAccountCollection collection = await GetTrustedSigningAccounts(); + + string accountName = Recording.GenerateAssetName("account-"); + + TrustedSigningAccountResource account = await CreateTrustedSigningAccount(collection, accountName); + Assert.IsNotNull(account); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/Scenario/TrustedSigningCertificateProfileTests.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/Scenario/TrustedSigningCertificateProfileTests.cs new file mode 100644 index 0000000000000..4a4502327760e --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/Scenario/TrustedSigningCertificateProfileTests.cs @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.TrustedSigning.Models; +using NUnit.Framework; +using NUnit.Framework.Interfaces; + +namespace Azure.ResourceManager.TrustedSigning.Tests.Scenario +{ + public class TrustedSigningCertificateProfileTests : TrustedSigningManagementTestBase + { + public TrustedSigningCertificateProfileTests(bool isAsync) : base(isAsync) + { + } + + public TrustedSigningCertificateProfileTests(bool isAsync, RecordedTestMode mode) : base(isAsync, mode) + { + } + + // Delete a certificate profile. + [Test] + [RecordedTest] + [Ignore("Need servie team to provide correct input data")] + public async Task Delete_DeleteACertificateProfile() + { + TrustedSigningAccountCollection accountCollection = await GetTrustedSigningAccounts(); + + string accountName = Recording.GenerateAssetName("account-"); + TrustedSigningAccountResource account = await CreateTrustedSigningAccount(accountCollection, accountName); + Assert.IsNotNull(account); + + TrustedSigningCertificateProfileCollection certProfileCollection = account.GetTrustedSigningCertificateProfiles(); + + string profileName = Recording.GenerateAssetName("profile-"); + TrustedSigningCertificateProfileResource certProfile = await CreateCertificateProfile(certProfileCollection, profileName); + Assert.IsNotNull(certProfile); + + ArmOperation op = await certProfile.DeleteAsync(WaitUntil.Completed); + Assert.IsTrue(op.HasCompleted); + } + + // Get details of a certificate profile. + [Test] + [RecordedTest] + [Ignore("Need servie team to provide correct input data")] + public async Task Get_GetDetailsOfACertificateProfile() + { + TrustedSigningAccountCollection accountCollection = await GetTrustedSigningAccounts(); + + string accountName = Recording.GenerateAssetName("account-"); + TrustedSigningAccountResource account = await CreateTrustedSigningAccount(accountCollection, accountName); + Assert.IsNotNull(account); + + TrustedSigningCertificateProfileCollection certProfileCollection = account.GetTrustedSigningCertificateProfiles(); + + string profileName = Recording.GenerateAssetName("profile-"); + TrustedSigningCertificateProfileResource certProfile = await CreateCertificateProfile(certProfileCollection, profileName); + Assert.IsNotNull(certProfile); + + TrustedSigningCertificateProfileResource certProfileResource = Client.GetTrustedSigningCertificateProfileResource(certProfile.Id); + TrustedSigningCertificateProfileResource result = await certProfileResource.GetAsync(); + Assert.IsNotNull(result); + } + + // List certificate profiles under a trusted signing account. + [Test] + [RecordedTest] + [Ignore("Need servie team to provide correct input data")] + public async Task GetAll_ListCertificateProfilesUnderATrustedSigningAccount() + { + TrustedSigningAccountCollection accountCollection = await GetTrustedSigningAccounts(); + + string accountName = Recording.GenerateAssetName("account-"); + TrustedSigningAccountResource account = await CreateTrustedSigningAccount(accountCollection, accountName); + Assert.IsNotNull(account); + + TrustedSigningCertificateProfileCollection certProfileCollection = account.GetTrustedSigningCertificateProfiles(); + + string profileName = Recording.GenerateAssetName("profile-"); + TrustedSigningCertificateProfileResource certProfile = await CreateCertificateProfile(certProfileCollection, profileName); + Assert.IsNotNull(certProfile); + + bool exist = false; + await foreach (TrustedSigningCertificateProfileResource item in certProfileCollection.GetAllAsync()) + { + Assert.IsNotNull(item); + if (item.Id == certProfile.Id) + { + exist = true; + break; + } + } + Assert.IsTrue(exist); + } + + // Create a certificate profile. + [Test] + [RecordedTest] + [Ignore("Need servie team to provide correct input data")] + public async Task CreateOrUpdate_CreateACertificateProfile() + { + TrustedSigningAccountCollection accountCollection = await GetTrustedSigningAccounts(); + + string accountName = Recording.GenerateAssetName("account-"); + TrustedSigningAccountResource account = await CreateTrustedSigningAccount(accountCollection, accountName); + Assert.IsNotNull(account); + + TrustedSigningCertificateProfileCollection certProfileCollection = account.GetTrustedSigningCertificateProfiles(); + + string profileName = Recording.GenerateAssetName("profile-"); + TrustedSigningCertificateProfileResource certProfile = await CreateCertificateProfile(certProfileCollection, profileName); + Assert.IsNotNull(certProfile); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/TrustedSigningManagementTestBase.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/TrustedSigningManagementTestBase.cs new file mode 100644 index 0000000000000..b2e88280ef0e1 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/TrustedSigningManagementTestBase.cs @@ -0,0 +1,83 @@ +// 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 Azure.ResourceManager.TrustedSigning.Models; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.TrustedSigning.Tests +{ + public class TrustedSigningManagementTestBase : ManagementRecordedTestBase + { + protected AzureLocation DefaultLocation => AzureLocation.EastUS; + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected TrustedSigningManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected TrustedSigningManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroupAsync() + { + var resourceGroupName = Recording.GenerateAssetName("testRG-"); + var rgOp = await DefaultSubscription.GetResourceGroups().CreateOrUpdateAsync( + WaitUntil.Completed, + resourceGroupName, + new ResourceGroupData(DefaultLocation) + { + Tags = + { + { "test", "env" } + } + }); + return rgOp.Value; + } + + protected async Task GetTrustedSigningAccounts() + { + var resourceGroup = await CreateResourceGroupAsync(); + return resourceGroup.GetTrustedSigningAccounts(); + } + + protected async Task CreateTrustedSigningAccount(TrustedSigningAccountCollection accountCollection, string accountName) + { + TrustedSigningAccountData data = new TrustedSigningAccountData(DefaultLocation) + { + SkuName = TrustedSigningSkuName.Basic, + }; + ArmOperation lro = await accountCollection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + return lro.Value; + } + + protected async Task CreateCertificateProfile(TrustedSigningCertificateProfileCollection certProfileCollection, string profileName) + { + // invoke the operation + TrustedSigningCertificateProfileData data = new TrustedSigningCertificateProfileData() + { + ProfileType = CertificateProfileType.PublicTrust, + IncludeStreetAddress = false, + IncludePostalCode = true, + IdentityValidationId = "00000000-1234-5678-3333-444444444444", + }; + ArmOperation lro = await certProfileCollection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + return lro.Value; + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/TrustedSigningManagementTestEnvironment.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/TrustedSigningManagementTestEnvironment.cs new file mode 100644 index 0000000000000..0e2b393f03329 --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/tests/TrustedSigningManagementTestEnvironment.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.TrustedSigning.Tests +{ + public class TrustedSigningManagementTestEnvironment : TestEnvironment + { + // Variables retrieved using GetRecordedVariable will be recorded in recorded tests + // Argument is the output name in the test-resources.json + public new string SubscriptionId => GetRecordedVariable("APPCONFIGURATION_SUBSCRIPTIONID"); + // Variables retrieved using GetVariable will not be recorded but the method will throw if the variable is not set + public string ResourceGroupName => GetVariable("APPCONFIGURATION_RESOURCEGROUPNAME"); + //Account details + public string AccountName => GetRecordedVariable("APPCONFIGURATION_ACCOUNTNAME"); + public string CertificateProfile => GetRecordedVariable("APPCONFIGURATION_CERTIFICATEPROFILE"); + } +} diff --git a/sdk/trustedsigning/ci.mgmt.yml b/sdk/trustedsigning/ci.mgmt.yml new file mode 100644 index 0000000000000..5b67358a44777 --- /dev/null +++ b/sdk/trustedsigning/ci.mgmt.yml @@ -0,0 +1,23 @@ +# 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/trustedsigning/ci.mgmt.yml + - sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/ + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: trustedsigning + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.TrustedSigning + safeName: AzureResourceManagerTrustedSigning