Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CloudMachineClient and related types into new package #46937

Merged
merged 9 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@
# ServiceLabel: %Bot Service
# ServiceOwners: @sgellock

# PRLabel: %CloudMachine

Check failure on line 183 in .github/CODEOWNERS

View check run for this annotation

Azure Pipelines / net - codeowners-linter - ci

.github/CODEOWNERS#L183

.github/CODEOWNERS(183,1): error : Error(s) on line 183 Source Line: # PRLabel: %CloudMachine -'CloudMachine' is not a valid label for this repository.
/sdk/cloudmachine/ @christothes @KrzysztofCwalina

# ServiceLabel: %ProvCloudMachineisioning

Check failure on line 186 in .github/CODEOWNERS

View check run for this annotation

Azure Pipelines / net - codeowners-linter - ci

.github/CODEOWNERS#L186

.github/CODEOWNERS(186,1): error : Error(s) on line 186 Source Line: # ServiceLabel: %ProvCloudMachineisioning -'ProvCloudMachineisioning' is not a valid label for this repository.
# AzureSdkOwners: @christothes @KrzysztofCwalina

# PRLabel: %Cognitive - Language
/sdk/cognitivelanguage/ @quentinRobinson @bidisha-c

Expand Down
34 changes: 34 additions & 0 deletions sdk/cloudmachine/Azure.CloudMachine.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure.CloudMachine", "Azure.CloudMachine", "{780138CF-68C6-4323-982F-F18989E2FA86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.CloudMachine", "Azure.CloudMachine\src\Azure.CloudMachine.csproj", "{0EA29D2F-41E0-4826-9CD4-111109A2CFF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.CloudMachine.Tests", "Azure.CloudMachine\tests\Azure.CloudMachine.Tests.csproj", "{8C1A29AE-E357-4C40-ACCC-7215FBFB368C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Release|Any CPU.Build.0 = Release|Any CPU
{8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0EA29D2F-41E0-4826-9CD4-111109A2CFF7} = {780138CF-68C6-4323-982F-F18989E2FA86}
{8C1A29AE-E357-4C40-ACCC-7215FBFB368C} = {780138CF-68C6-4323-982F-F18989E2FA86}
EndGlobalSection
EndGlobal
11 changes: 11 additions & 0 deletions sdk/cloudmachine/Azure.CloudMachine/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Release History

## 1.0.0-beta.1 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes
6 changes: 6 additions & 0 deletions sdk/cloudmachine/Azure.CloudMachine/Directory.Build.props
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>
6 changes: 6 additions & 0 deletions sdk/cloudmachine/Azure.CloudMachine/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Import the common SDK build targets. -->
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.targets))\Directory.Build.targets"
Condition="'$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.targets))' != ''" />

</Project>
57 changes: 57 additions & 0 deletions sdk/cloudmachine/Azure.CloudMachine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Azure CloudMachine client library for .NET

TODO

## Getting started

### Install the package

Install the client library for .NET with [NuGet](https://www.nuget.org/ ):

```dotnetcli
dotnet add package Azure.CloudMachine --prerelease
```

### Prerequisites

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

### Authenticate the Client

## Key concepts

TODO.

## Examples

## 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

## 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 <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
(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
<opencode@microsoft.com> with any other questions or comments.

<!-- LINKS -->
[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/
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
namespace Azure.CloudMachine
{
public partial class CloudMachineClient : Azure.CloudMachine.CloudMachineWorkspace
{
protected CloudMachineClient() : base (default(Azure.Core.TokenCredential), default(Microsoft.Extensions.Configuration.IConfiguration)) { }
public CloudMachineClient(Azure.Core.TokenCredential credential = null, Microsoft.Extensions.Configuration.IConfiguration configuration = null) : base (default(Azure.Core.TokenCredential), default(Microsoft.Extensions.Configuration.IConfiguration)) { }
public Azure.CloudMachine.MessagingServices Messaging { get { throw null; } }
public Azure.CloudMachine.StorageServices Storage { get { throw null; } }
}
public partial class CloudMachineWorkspace : Azure.Core.ClientWorkspace
{
public CloudMachineWorkspace(Azure.Core.TokenCredential credential = null, Microsoft.Extensions.Configuration.IConfiguration configuration = null) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public string Id { get { 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 Azure.Core.ClientConnectionOptions GetConnectionOptions(System.Type clientType, string instanceId = null) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override int GetHashCode() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override string ToString() { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct MessagingServices
{
private readonly object _dummy;
private readonly int _dummyPrimitive;
public void SendMessage(object serializable) { }
public void WhenMessageReceived(System.Action<string> received) { }
}
public partial class StorageFile
{
internal StorageFile() { }
public System.Threading.CancellationToken CancellationToken { get { throw null; } }
public string Path { get { throw null; } }
public string RequestId { get { throw null; } }
public void Delete() { }
public System.BinaryData Download() { 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 implicit operator Azure.Response (Azure.CloudMachine.StorageFile result) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override string ToString() { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct StorageServices
{
private readonly object _dummy;
private readonly int _dummyPrimitive;
public void DeleteBlob(string path) { }
public System.BinaryData DownloadBlob(string path) { throw null; }
public string UploadBinaryData(System.BinaryData data, string name = null, bool overwrite = false) { throw null; }
public string UploadBytes(byte[] bytes, string name = null, bool overwrite = false) { throw null; }
public string UploadBytes(System.ReadOnlyMemory<byte> bytes, string name = null, bool overwrite = false) { throw null; }
public string UploadJson(object json, string name = null, bool overwrite = false) { throw null; }
public string UploadStream(System.IO.Stream fileStream, string name = null, bool overwrite = false) { throw null; }
public void WhenBlobUploaded(System.Action<Azure.CloudMachine.StorageFile> function) { }
}
}
namespace Azure.CloudMachine.KeyVault
{
public static partial class KeyVaultExtensions
{
public static Azure.Security.KeyVault.Secrets.SecretClient GetKeyVaultSecretsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
}
}
namespace Azure.CloudMachine.OpenAI
{
public static partial class AzureOpenAIExtensions
{
public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
}
}
namespace Azure.Core
{
public partial class ClientCache
{
public ClientCache() { }
public T Get<T>(System.Func<T> value, string id = null) where T : class { throw null; }
}
public enum ClientConnectionKind
{
EntraId = 0,
ApiKey = 1,
OutOfBand = 2,
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct ClientConnectionOptions
{
private readonly object _dummy;
private readonly int _dummyPrimitive;
public ClientConnectionOptions(string subclientId) { throw null; }
public ClientConnectionOptions(System.Uri endpoint, Azure.Core.TokenCredential credential) { throw null; }
public ClientConnectionOptions(System.Uri endpoint, string apiKey) { throw null; }
public string ApiKeyCredential { get { throw null; } }
public Azure.Core.ClientConnectionKind ConnectionKind { get { throw null; } }
public System.Uri Endpoint { get { throw null; } }
public string Id { get { throw null; } }
public Azure.Core.TokenCredential TokenCredential { get { throw null; } }
}
public abstract partial class ClientWorkspace
{
protected ClientWorkspace() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public Azure.Core.ClientCache Subclients { get { throw null; } }
public abstract Azure.Core.ClientConnectionOptions GetConnectionOptions(System.Type clientType, string instanceId = null);
}
}
12 changes: 12 additions & 0 deletions sdk/cloudmachine/Azure.CloudMachine/samples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
page_type: sample
languages:
- csharp
products:
# Including relevant stubs from https://review.docs.microsoft.com/help/contribute/metadata-taxonomies#product
- azure
name: Azure.CloudMachine samples for .NET
description: Samples for the Azure.CloudMachine client library.
---

# Azure.CloudMachine Samples
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Azure.CloudMachine simplifies getting started with Azure in .NET.</Description>
<Version>1.0.0-beta.1</Version>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<LangVersion>12</LangVersion>

<!-- Disable warning CS1591: Missing XML comment for publicly visible type or member -->
<NoWarn>CS1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Core" />
<PackageReference Include="Azure.AI.OpenAI" />
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.Messaging.ServiceBus" />
<PackageReference Include="Azure.Messaging.EventGrid" />
<PackageReference Include="Azure.Storage.Blobs" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" VersionOverride="8.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace Azure.Core;
// TODO: this is a very demo implementation. We need to do better
public class ClientCache
{
private readonly Dictionary<(Type, string?), object> _clients = new Dictionary<(Type, string?), object>();
private readonly Dictionary<(Type, string), object> _clients = new Dictionary<(Type, string), object>();

public T Get<T>(Func<T> value, string? id = default) where T: class
public T Get<T>(Func<T> value, string id = default) where T: class
{
var client = (typeof(T), id);
lock (_clients)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Azure.Core;

public abstract class ClientWorkspace
{
public abstract ClientConnectionOptions GetConnectionOptions(Type clientType, string? instanceId = default);
public abstract ClientConnectionOptions GetConnectionOptions(Type clientType, string instanceId = default);

[EditorBrowsable(EditorBrowsableState.Never)]
public ClientCache Subclients { get; } = new ClientCache();
Expand Down Expand Up @@ -36,10 +36,10 @@ public ClientConnectionOptions(string subclientId)

public ClientConnectionKind ConnectionKind { get; }

public Uri? Endpoint { get; }
public string? Id { get; }
public string? ApiKeyCredential { get; }
public TokenCredential? TokenCredential { get; }
public Uri Endpoint { get; }
public string Id { get; }
public string ApiKeyCredential { get; }
public TokenCredential TokenCredential { get; }
}

public enum ClientConnectionKind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ namespace Azure.CloudMachine;

public partial class CloudMachineClient : CloudMachineWorkspace
{
public CloudMachineClient(TokenCredential? credential = default, IConfiguration? configuration = default)
protected CloudMachineClient()
{ }
#pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service.
public CloudMachineClient(TokenCredential credential = default, IConfiguration configuration = default)
#pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service.
: base(credential, configuration)
{
Messaging = new MessagingServices(this);
Expand Down
Loading
Loading