Skip to content

Commit

Permalink
initial checkin for core / tests (#18968)
Browse files Browse the repository at this point in the history
* initial checkin for core / tests

* Add readme.md file

* Fix header in readme

* remove autorest until we convert off hand written types

* update azure.core reference
remove sets to tags
ignore tests which require credentials for now

* Add the proto client which will be used until the autogen work is complete

* Add missing readmes for proto client

* update to require linq 4.0.0 so that don't have to upgrade bcl

* add changlog for CI

* change system.linq.async to update

* update to use source vs binary for the temporary generation of Azure.ResourceManager.Authorization

* Add changelog for azure.resourcemanager.authorization and update version to be beta

* update typos in readme

* update name of proto client sln

* merge in changes from proto repo this week

* fixed unit test failures
missed a few files from the merge from proto repo
updated compute and network sdk version to use latest azure.core with readonly list types

* ignore tests which require live azure until 5122 is closed

* Update failing scenario test
  • Loading branch information
m-nash authored Feb 27, 2021
1 parent ced985d commit 941df0c
Show file tree
Hide file tree
Showing 230 changed files with 20,443 additions and 0 deletions.
3 changes: 3 additions & 0 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
<PackageReference Update="System.ValueTuple" Version="4.5.0" />
<PackageReference Update="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
<PackageReference Update="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Update="System.Collections.Immutable" Version="1.3.1" />
<PackageReference Update="System.Linq.Async" Version="4.0.0" />

<!-- Azure SDK packages -->
<PackageReference Update="Azure.Core" Version="1.9.0" />
Expand All @@ -81,6 +83,7 @@
<PackageReference Update="Azure.Security.KeyVault.Secrets" Version="4.0.2" />
<PackageReference Update="Azure.Security.KeyVault.Keys" Version="4.0.2" />
<PackageReference Update="Azure.Storage.Blobs" Version="12.8.0" />
<PackageReference Update="Azure.ResourceManager.Resources" Version="1.0.0-preview.2" />

<!-- Other approved packages -->
<PackageReference Update="Microsoft.Azure.Amqp" Version="2.4.9" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31019.35
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core", "..\..\core\Azure.Core\src\Azure.Core.csproj", "{856C6092-55EB-4C02-B7D0-9846EDD70745}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{62AF7C88-CE3F-416E-B18E-BC6F884C89E2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.Core", "src\Azure.ResourceManager.Core.csproj", "{010FE057-7BB5-4F8C-BB9A-6378144F4CA8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.Core.Tests", "tests\Azure.ResourceManager.Core.Tests.csproj", "{83E7651C-7FBE-45AA-B740-31FE9A3E44C7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{856C6092-55EB-4C02-B7D0-9846EDD70745}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{856C6092-55EB-4C02-B7D0-9846EDD70745}.Debug|Any CPU.Build.0 = Debug|Any CPU
{856C6092-55EB-4C02-B7D0-9846EDD70745}.Release|Any CPU.ActiveCfg = Release|Any CPU
{856C6092-55EB-4C02-B7D0-9846EDD70745}.Release|Any CPU.Build.0 = Release|Any CPU
{62AF7C88-CE3F-416E-B18E-BC6F884C89E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62AF7C88-CE3F-416E-B18E-BC6F884C89E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62AF7C88-CE3F-416E-B18E-BC6F884C89E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62AF7C88-CE3F-416E-B18E-BC6F884C89E2}.Release|Any CPU.Build.0 = Release|Any CPU
{010FE057-7BB5-4F8C-BB9A-6378144F4CA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{010FE057-7BB5-4F8C-BB9A-6378144F4CA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{010FE057-7BB5-4F8C-BB9A-6378144F4CA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{010FE057-7BB5-4F8C-BB9A-6378144F4CA8}.Release|Any CPU.Build.0 = Release|Any CPU
{83E7651C-7FBE-45AA-B740-31FE9A3E44C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83E7651C-7FBE-45AA-B740-31FE9A3E44C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83E7651C-7FBE-45AA-B740-31FE9A3E44C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{83E7651C-7FBE-45AA-B740-31FE9A3E44C7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FA17550D-A020-4DD7-B3A3-0228FC290A1F}
EndGlobalSection
EndGlobal
5 changes: 5 additions & 0 deletions sdk/resourcemanager/Azure.ResourceManager.Core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release History

## 1.0.0-beta.1 (Unreleased)

-Initial checkin
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Add any shared properties you want for the projects under this package directory that need to be set before the auto imported Directory.Build.props
-->
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.props))\Directory.Build.props" />
</Project>
77 changes: 77 additions & 0 deletions sdk/resourcemanager/Azure.ResourceManager.Core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Azure ResourceManager Core client library for .NET

This package follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html) which provide a number of core capabilities that are shared amongst all Azure SDKs, including the intuitive Azure Identity library, an HTTP Pipeline with custom policies, error-handling, distributed tracing, and much more.

## Getting started

### Install the package

Install the Azure Resources management core library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.Core -Version 1.0.0-beta.1
```

### Prerequisites

* You must have an [Azure subscription](https://azure.microsoft.com/free/)

### Authenticate the Client

To create an authenticated client and start interacting with Azure resources, please see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/master/doc/mgmt_preview_quickstart.md)

## Key concepts

Key concepts of the Azure .NET SDK 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/master/doc/mgmt_preview_quickstart.md)
- [API References](https://docs.microsoft.com/dotnet/api/?view=azure-dotnet)
- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/master/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://docs.microsoft.com/samples/browse/?branch=master&languages=csharp&term=managing%20using%20Azure%20.NET%20SDK)

## 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 on Azure SDK, please refer to [this website](https://azure.github.io/azure-sdk/)

## Contributing

For details on contributing to this repository, see the contributing
guide.

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 <https://cla.microsoft.com>.

When you submit a pull request, a CLA-bot will automatically determine
whether you need to provide a CLA and decorate the PR appropriately
(e.g., label, comment). Simply follow the instructions provided by the
bot. You will only need to do this once across all repositories using
our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For
more information see the Code of Conduct FAQ or contact
<opencode@microsoft.com> with any additional questions or comments.

<!-- LINKS -->
[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization
[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide

![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net%2Fsdk%2Ftemplate%2FAzure.Template%2FREADME.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;

namespace Azure.ResourceManager.Core
{
/// <summary>
/// Placeholder class, used to convert the gewneric type argument for a response from the underlyign rest API to the
/// desired type argument in the response
/// </summary>
/// <typeparam name="TOperations"> The <see cref="ResourceOperationsBase"/> to convert the TModel into. </typeparam>
/// <typeparam name="TModel"> The model returned by the existing serivce calls. </typeparam>
public class PhArmResponse<TOperations, TModel> : ArmResponse<TOperations>
where TOperations : class
where TModel : class
{
private readonly Func<TModel, TOperations> _converter;
private readonly Response<TModel> _wrapped;

/// <summary>
/// Initializes a new instance of the <see cref="PhArmResponse{TOperations, TModel}"/> class.
/// </summary>
/// <param name="wrapped"> The results to wrap. </param>
/// <param name="converter"> The function used to convert from existing type to new type. </param>
public PhArmResponse(Response<TModel> wrapped, Func<TModel, TOperations> converter)
{
_wrapped = wrapped;
_converter = converter;
}

/// <inheritdoc/>
public override TOperations Value => _converter(_wrapped.Value);

/// <inheritdoc/>
public override Response GetRawResponse()
{
return _wrapped.GetRawResponse();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Azure.ResourceManager.Core.Adapters
{
/// <summary>
/// A class repreesnting an AsyncPageable that executes a given task before retrieving the first page of results
/// </summary>
/// <typeparam name="TOperations"> The type of <see cref="ResourceOperationsBase"/> that will be returned. </typeparam>
public class PhTaskDeferringAsyncPageable<TOperations> : AsyncPageable<TOperations>
where TOperations : notnull
{
private readonly Func<Task<AsyncPageable<TOperations>>> _task;

/// <summary>
/// Initializes a new instance of the <see cref="PhTaskDeferringAsyncPageable{TOperations}"/> class.
/// </summary>
/// <param name="task"> The function to execute returning the AsyncPageable task. </param>
public PhTaskDeferringAsyncPageable(Func<Task<AsyncPageable<TOperations>>> task)
{
_task = task;
}

/// <inheritdoc/>
public override async IAsyncEnumerable<Page<TOperations>> AsPages(
string continuationToken = null,
int? pageSizeHint = null)
{
await foreach (var page in (await _task().ConfigureAwait(false)).AsPages().ConfigureAwait(false))
{
yield return page;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Azure.ResourceManager.Core
{
/// <summary>
/// Returns an AsyncPageable that transforms each page of contents after they are retrieved from the server
/// according to the profived transformation function
/// </summary>
/// <typeparam name="TModel"> The model returned by existing AsyncPageable methods. </typeparam>
/// <typeparam name="TOperations"> The <see cref="ResourceOperationsBase"/> to convert TModel into. </typeparam>
public class PhWrappingAsyncPageable<TModel, TOperations> : AsyncPageable<TOperations>
where TOperations : class
where TModel : class
{
private readonly Func<TModel, TOperations> _converter;
private readonly IEnumerable<AsyncPageable<TModel>> _wrapped;

/// <summary>
/// Initializes a new instance of the <see cref="PhWrappingAsyncPageable{TModel, TOperations}"/> class.
/// </summary>
/// <param name="wrapped"> The results to wrap. </param>
/// <param name="converter"> The function used to convert from existing type to new type. </param>
public PhWrappingAsyncPageable(AsyncPageable<TModel> wrapped, Func<TModel, TOperations> converter)
{
_wrapped = new[] { wrapped };
_converter = converter;
}

/// <summary>
/// Initializes a new instance of the <see cref="PhWrappingAsyncPageable{TModel, TOperations}"/> class.
/// </summary>
/// <param name="wrapped"> The results to wrap. </param>
/// <param name="converter"> The function used to convert from existing type to new type. </param>
public PhWrappingAsyncPageable(IEnumerable<AsyncPageable<TModel>> wrapped, Func<TModel, TOperations> converter)
{
_wrapped = wrapped;
_converter = converter;
}

/// <inheritdoc/>
public override async IAsyncEnumerable<Page<TOperations>> AsPages(
string continuationToken = null,
int? pageSizeHint = null)
{
foreach (var pageEnum in _wrapped)
{
await foreach (var page in pageEnum.AsPages().WithCancellation(CancellationToken))
{
yield return new WrappingPage<TModel, TOperations>(page, _converter);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;

namespace Azure.ResourceManager.Core
{
/// <summary>
/// This class allows performing conversions on pages of data as they are accessed - used in the prototype to convett
/// between underlying model types and the new model types that extend Resource,
/// and also for returning Operations classes for those underlying objects.
/// </summary>
/// <typeparam name="TModel"> The type parameter of the Pageable we are wrapping. </typeparam>
/// <typeparam name="TOperations"> The desired type parameter of the returned pageable. </typeparam>
public class PhWrappingPageable<TModel, TOperations> : Pageable<TOperations>
where TOperations : class
where TModel : class
{
private readonly Func<TModel, TOperations> _converter;
private readonly IEnumerable<Pageable<TModel>> _wrapped;

/// <summary>
/// Initializes a new instance of the <see cref="PhWrappingPageable{TModel, TOperations}"/> class.
/// </summary>
/// <param name="wrapped"> The results to wrap. </param>
/// <param name="converter"> The function used to convert from existing type to new type. </param>
public PhWrappingPageable(Pageable<TModel> wrapped, Func<TModel, TOperations> converter)
{
_wrapped = new[] { wrapped };
_converter = converter;
}

/// <summary>
/// Initializes a new instance of the <see cref="PhWrappingPageable{TModel, TOperations}"/> class.
/// </summary>
/// <param name="wrapped"> The results to wrap. </param>
/// <param name="converter"> The function used to convert from existing type to new type. </param>
public PhWrappingPageable(IEnumerable<Pageable<TModel>> wrapped, Func<TModel, TOperations> converter)
{
_wrapped = wrapped;
_converter = converter;
}

/// <inheritdoc/>
public override IEnumerable<Page<TOperations>> AsPages(string continuationToken = null, int? pageSizeHint = null)
{
foreach (var pages in _wrapped)
{
foreach (var page in pages.AsPages())
{
yield return new WrappingPage<TModel, TOperations>(page, _converter);
}
}
}
}
}
Loading

0 comments on commit 941df0c

Please sign in to comment.