diff --git a/sdk/microsoft.app/Microsoft.App/Microsoft.App.sln b/sdk/microsoft.app/Microsoft.App/Microsoft.App.sln new file mode 100644 index 000000000000..c81a7592cc4f --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/Microsoft.App.sln @@ -0,0 +1,50 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.App", "src\Microsoft.App.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.App.Tests", "tests\Microsoft.App.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/AppClient.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/AppClient.cs new file mode 100644 index 000000000000..e7e483b53f3d --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/AppClient.cs @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Microsoft.App +{ + // Data plane generated client. + /// The App service client. + public partial class AppClient + { + private static readonly string[] AuthorizationScopes = new string[] { "https://dynamicsessions.io/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of AppClient for mocking. + protected AppClient() + { + } + + /// Initializes a new instance of AppClient. + /// The management endpoint of the session pool. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public AppClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AppClientOptions()) + { + } + + /// Initializes a new instance of AppClient. + /// The management endpoint of the session pool. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public AppClient(Uri endpoint, TokenCredential credential, AppClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AppClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// Execute code in a session. + /// The identifier of the session. + /// The request to execute code. + /// The cancellation token to use. + /// or is null. + /// + public virtual async Task> ExecuteCodeAsync(string identifier, SessionCodeExecutionRequest codeExecutionRequest, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(codeExecutionRequest, nameof(codeExecutionRequest)); + + using RequestContent content = codeExecutionRequest.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await ExecuteCodeAsync(identifier, content, context).ConfigureAwait(false); + return Response.FromValue(SessionCodeExecutionResult.FromResponse(response), response); + } + + /// Execute code in a session. + /// The identifier of the session. + /// The request to execute code. + /// The cancellation token to use. + /// or is null. + /// + public virtual Response ExecuteCode(string identifier, SessionCodeExecutionRequest codeExecutionRequest, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(codeExecutionRequest, nameof(codeExecutionRequest)); + + using RequestContent content = codeExecutionRequest.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = ExecuteCode(identifier, content, context); + return Response.FromValue(SessionCodeExecutionResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Execute code in a session. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the session. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task ExecuteCodeAsync(string identifier, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AppClient.ExecuteCode"); + scope.Start(); + try + { + using HttpMessage message = CreateExecuteCodeRequest(identifier, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Execute code in a session. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the session. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response ExecuteCode(string identifier, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AppClient.ExecuteCode"); + scope.Start(); + try + { + using HttpMessage message = CreateExecuteCodeRequest(identifier, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get the code execution result. + /// The identifier of the session. + /// The identifier of code execution. + /// The cancellation token to use. + /// or is null. + /// + public virtual async Task> GetCodeExecutionResultAsync(string identifier, string executionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(executionId, nameof(executionId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetCodeExecutionResultAsync(identifier, executionId, context).ConfigureAwait(false); + return Response.FromValue(SessionCodeExecutionResult.FromResponse(response), response); + } + + /// Get the code execution result. + /// The identifier of the session. + /// The identifier of code execution. + /// The cancellation token to use. + /// or is null. + /// + public virtual Response GetCodeExecutionResult(string identifier, string executionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(executionId, nameof(executionId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetCodeExecutionResult(identifier, executionId, context); + return Response.FromValue(SessionCodeExecutionResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get the code execution result. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the session. + /// The identifier of code execution. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetCodeExecutionResultAsync(string identifier, string executionId, RequestContext context) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(executionId, nameof(executionId)); + + using var scope = ClientDiagnostics.CreateScope("AppClient.GetCodeExecutionResult"); + scope.Start(); + try + { + using HttpMessage message = CreateGetCodeExecutionResultRequest(identifier, executionId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get the code execution result. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the session. + /// The identifier of code execution. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetCodeExecutionResult(string identifier, string executionId, RequestContext context) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(executionId, nameof(executionId)); + + using var scope = ClientDiagnostics.CreateScope("AppClient.GetCodeExecutionResult"); + scope.Start(); + try + { + using HttpMessage message = CreateGetCodeExecutionResultRequest(identifier, executionId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + private SessionResourceFiles _cachedSessionResourceFiles; + + /// Initializes a new instance of SessionResourceFiles. + public virtual SessionResourceFiles GetSessionResourceFilesClient() + { + return Volatile.Read(ref _cachedSessionResourceFiles) ?? Interlocked.CompareExchange(ref _cachedSessionResourceFiles, new SessionResourceFiles(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, _apiVersion), null) ?? _cachedSessionResourceFiles; + } + + internal HttpMessage CreateExecuteCodeRequest(string identifier, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/codeExecute", false); + uri.AppendQuery("identifier", identifier, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetCodeExecutionResultRequest(string identifier, string executionId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/codeExecutionResult", false); + uri.AppendQuery("identifier", identifier, true); + uri.AppendQuery("executionId", executionId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/AppClientOptions.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/AppClientOptions.cs new file mode 100644 index 000000000000..b63f1f4e612b --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/AppClientOptions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Microsoft.App +{ + /// Client options for AppClient. + public partial class AppClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2024_09_01; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2024-09-01". + V2024_09_01 = 1, + } + + internal string Version { get; } + + /// Initializes new instance of AppClientOptions. + public AppClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2024_09_01 => "2024-09-01", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/CodeExecutionStatus.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/CodeExecutionStatus.cs new file mode 100644 index 000000000000..b36411e9f003 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/CodeExecutionStatus.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 Microsoft.App +{ + /// Code execution status. + public readonly partial struct CodeExecutionStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CodeExecutionStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SuccessValue = "Success"; + private const string FailureValue = "Failure"; + + /// The code execution succeeded. + public static CodeExecutionStatus Success { get; } = new CodeExecutionStatus(SuccessValue); + /// The code execution failed. + public static CodeExecutionStatus Failure { get; } = new CodeExecutionStatus(FailureValue); + /// Determines if two values are the same. + public static bool operator ==(CodeExecutionStatus left, CodeExecutionStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CodeExecutionStatus left, CodeExecutionStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CodeExecutionStatus(string value) => new CodeExecutionStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CodeExecutionStatus other && Equals(other); + /// + public bool Equals(CodeExecutionStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/CodeInputType.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/CodeInputType.cs new file mode 100644 index 000000000000..61707294e064 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/CodeInputType.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 Microsoft.App +{ + /// Code input type. + public readonly partial struct CodeInputType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CodeInputType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InlineValue = "Inline"; + private const string InlineBase64Value = "InlineBase64"; + private const string InlineTextValue = "InlineText"; + + /// Inline. + public static CodeInputType Inline { get; } = new CodeInputType(InlineValue); + /// InlineBase64. + public static CodeInputType InlineBase64 { get; } = new CodeInputType(InlineBase64Value); + /// InlineText. + public static CodeInputType InlineText { get; } = new CodeInputType(InlineTextValue); + /// Determines if two values are the same. + public static bool operator ==(CodeInputType left, CodeInputType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CodeInputType left, CodeInputType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CodeInputType(string value) => new CodeInputType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CodeInputType other && Equals(other); + /// + public bool Equals(CodeInputType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/Docs/AppClient.xml b/sdk/microsoft.app/Microsoft.App/src/Generated/Docs/AppClient.xml new file mode 100644 index 000000000000..86e4a942e8f3 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/Docs/AppClient.xml @@ -0,0 +1,333 @@ + + + + + +This sample shows how to call ExecuteCodeAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +SessionCodeExecutionRequest codeExecutionRequest = new SessionCodeExecutionRequest( +CodeInputType.Inline, +ExecutionType.Synchronous, +NetworkStatus.EgressEnabled, +MultiArrayStatus.MultiArrayEnabled, +"", +1234L); +Response response = await client.ExecuteCodeAsync("", codeExecutionRequest); +]]> +This sample shows how to call ExecuteCodeAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +SessionCodeExecutionRequest codeExecutionRequest = new SessionCodeExecutionRequest( +CodeInputType.Inline, +ExecutionType.Synchronous, +NetworkStatus.EgressEnabled, +MultiArrayStatus.MultiArrayEnabled, +"", +1234L); +Response response = await client.ExecuteCodeAsync("", codeExecutionRequest); +]]> + + + +This sample shows how to call ExecuteCode. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +SessionCodeExecutionRequest codeExecutionRequest = new SessionCodeExecutionRequest( +CodeInputType.Inline, +ExecutionType.Synchronous, +NetworkStatus.EgressEnabled, +MultiArrayStatus.MultiArrayEnabled, +"", +1234L); +Response response = client.ExecuteCode("", codeExecutionRequest); +]]> +This sample shows how to call ExecuteCode with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +SessionCodeExecutionRequest codeExecutionRequest = new SessionCodeExecutionRequest( +CodeInputType.Inline, +ExecutionType.Synchronous, +NetworkStatus.EgressEnabled, +MultiArrayStatus.MultiArrayEnabled, +"", +1234L); +Response response = client.ExecuteCode("", codeExecutionRequest); +]]> + + + +This sample shows how to call ExecuteCodeAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + codeInputType = "Inline", + executionType = "Synchronous", + networkStatus = "EgressEnabled", + multiArrayStatus = "MultiArrayEnabled", + code = "", + timeoutInSeconds = 1234L, +}); +Response response = await client.ExecuteCodeAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("codeInputType").ToString()); +Console.WriteLine(result.GetProperty("executionType").ToString()); +Console.WriteLine(result.GetProperty("networkStatus").ToString()); +Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); +Console.WriteLine(result.GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("stdout").ToString()); +Console.WriteLine(result.GetProperty("stderr").ToString()); +Console.WriteLine(result.GetProperty("result").ToString()); +Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); +]]> +This sample shows how to call ExecuteCodeAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + codeInputType = "Inline", + executionType = "Synchronous", + networkStatus = "EgressEnabled", + multiArrayStatus = "MultiArrayEnabled", + code = "", + timeoutInSeconds = 1234L, +}); +Response response = await client.ExecuteCodeAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("codeInputType").ToString()); +Console.WriteLine(result.GetProperty("executionType").ToString()); +Console.WriteLine(result.GetProperty("networkStatus").ToString()); +Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); +Console.WriteLine(result.GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("stdout").ToString()); +Console.WriteLine(result.GetProperty("stderr").ToString()); +Console.WriteLine(result.GetProperty("result").ToString()); +Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); +]]> + + + +This sample shows how to call ExecuteCode and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + codeInputType = "Inline", + executionType = "Synchronous", + networkStatus = "EgressEnabled", + multiArrayStatus = "MultiArrayEnabled", + code = "", + timeoutInSeconds = 1234L, +}); +Response response = client.ExecuteCode("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("codeInputType").ToString()); +Console.WriteLine(result.GetProperty("executionType").ToString()); +Console.WriteLine(result.GetProperty("networkStatus").ToString()); +Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); +Console.WriteLine(result.GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("stdout").ToString()); +Console.WriteLine(result.GetProperty("stderr").ToString()); +Console.WriteLine(result.GetProperty("result").ToString()); +Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); +]]> +This sample shows how to call ExecuteCode with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + codeInputType = "Inline", + executionType = "Synchronous", + networkStatus = "EgressEnabled", + multiArrayStatus = "MultiArrayEnabled", + code = "", + timeoutInSeconds = 1234L, +}); +Response response = client.ExecuteCode("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("codeInputType").ToString()); +Console.WriteLine(result.GetProperty("executionType").ToString()); +Console.WriteLine(result.GetProperty("networkStatus").ToString()); +Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); +Console.WriteLine(result.GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("stdout").ToString()); +Console.WriteLine(result.GetProperty("stderr").ToString()); +Console.WriteLine(result.GetProperty("result").ToString()); +Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); +]]> + + + +This sample shows how to call GetCodeExecutionResultAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +Response response = await client.GetCodeExecutionResultAsync("", ""); +]]> +This sample shows how to call GetCodeExecutionResultAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +Response response = await client.GetCodeExecutionResultAsync("", ""); +]]> + + + +This sample shows how to call GetCodeExecutionResult. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +Response response = client.GetCodeExecutionResult("", ""); +]]> +This sample shows how to call GetCodeExecutionResult with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +Response response = client.GetCodeExecutionResult("", ""); +]]> + + + +This sample shows how to call GetCodeExecutionResultAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +Response response = await client.GetCodeExecutionResultAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("codeInputType").ToString()); +Console.WriteLine(result.GetProperty("executionType").ToString()); +Console.WriteLine(result.GetProperty("networkStatus").ToString()); +Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); +Console.WriteLine(result.GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("stdout").ToString()); +Console.WriteLine(result.GetProperty("stderr").ToString()); +Console.WriteLine(result.GetProperty("result").ToString()); +Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); +]]> +This sample shows how to call GetCodeExecutionResultAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +Response response = await client.GetCodeExecutionResultAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("codeInputType").ToString()); +Console.WriteLine(result.GetProperty("executionType").ToString()); +Console.WriteLine(result.GetProperty("networkStatus").ToString()); +Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); +Console.WriteLine(result.GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("stdout").ToString()); +Console.WriteLine(result.GetProperty("stderr").ToString()); +Console.WriteLine(result.GetProperty("result").ToString()); +Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); +]]> + + + +This sample shows how to call GetCodeExecutionResult and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +Response response = client.GetCodeExecutionResult("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("codeInputType").ToString()); +Console.WriteLine(result.GetProperty("executionType").ToString()); +Console.WriteLine(result.GetProperty("networkStatus").ToString()); +Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); +Console.WriteLine(result.GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("stdout").ToString()); +Console.WriteLine(result.GetProperty("stderr").ToString()); +Console.WriteLine(result.GetProperty("result").ToString()); +Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); +]]> +This sample shows how to call GetCodeExecutionResult with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +AppClient client = new AppClient(endpoint, credential); + +Response response = client.GetCodeExecutionResult("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("codeInputType").ToString()); +Console.WriteLine(result.GetProperty("executionType").ToString()); +Console.WriteLine(result.GetProperty("networkStatus").ToString()); +Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); +Console.WriteLine(result.GetProperty("code").ToString()); +Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("stdout").ToString()); +Console.WriteLine(result.GetProperty("stderr").ToString()); +Console.WriteLine(result.GetProperty("result").ToString()); +Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/Docs/SessionResourceFiles.xml b/sdk/microsoft.app/Microsoft.App/src/Generated/Docs/SessionResourceFiles.xml new file mode 100644 index 000000000000..689f0e2acc70 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/Docs/SessionResourceFiles.xml @@ -0,0 +1,467 @@ + + + + + +This sample shows how to call GetFileMetadataAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.GetFileMetadataAsync("", ""); +]]> +This sample shows how to call GetFileMetadataAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.GetFileMetadataAsync("", ""); +]]> + + + +This sample shows how to call GetFileMetadata. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.GetFileMetadata("", ""); +]]> +This sample shows how to call GetFileMetadata with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.GetFileMetadata("", ""); +]]> + + + +This sample shows how to call GetFileMetadataAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.GetFileMetadataAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +]]> +This sample shows how to call GetFileMetadataAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.GetFileMetadataAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +]]> + + + +This sample shows how to call GetFileMetadata and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.GetFileMetadata("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +]]> +This sample shows how to call GetFileMetadata with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.GetFileMetadata("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +]]> + + + +This sample shows how to call DeleteFileAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.DeleteFileAsync("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteFileAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.DeleteFileAsync("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteFile. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.DeleteFile("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteFile with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.DeleteFile("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DownloadFileAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.DownloadFileAsync("", ""); +]]> +This sample shows how to call DownloadFileAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.DownloadFileAsync("", ""); +]]> + + + +This sample shows how to call DownloadFile. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.DownloadFile("", ""); +]]> +This sample shows how to call DownloadFile with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.DownloadFile("", ""); +]]> + + + +This sample shows how to call DownloadFileAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.DownloadFileAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call DownloadFileAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.DownloadFileAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call DownloadFile and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.DownloadFile("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call DownloadFile with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.DownloadFile("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call UploadFileAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.UploadFileAsync("", "", null); +]]> +This sample shows how to call UploadFileAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = await client.UploadFileAsync("", "", null); +]]> + + + +This sample shows how to call UploadFile. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.UploadFile("", "", null); +]]> +This sample shows how to call UploadFile with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +Response response = client.UploadFile("", "", null); +]]> + + + +This sample shows how to call UploadFileAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +using RequestContent content = RequestContent.Create(new +{ + file = File.OpenRead(""), +}); +Response response = await client.UploadFileAsync("", "", content, "multipart/form-data"); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +]]> +This sample shows how to call UploadFileAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +using RequestContent content = RequestContent.Create(new +{ + file = File.OpenRead(""), +}); +Response response = await client.UploadFileAsync("", "", content, "multipart/form-data"); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +]]> + + + +This sample shows how to call UploadFile and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +using RequestContent content = RequestContent.Create(new +{ + file = File.OpenRead(""), +}); +Response response = client.UploadFile("", "", content, "multipart/form-data"); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +]]> +This sample shows how to call UploadFile with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +using RequestContent content = RequestContent.Create(new +{ + file = File.OpenRead(""), +}); +Response response = client.UploadFile("", "", content, "multipart/form-data"); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +]]> + + + +This sample shows how to call GetAllFilesMetadataAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +await foreach (SessionResourceFile item in client.GetAllFilesMetadataAsync("")) +{ +} +]]> +This sample shows how to call GetAllFilesMetadataAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +await foreach (SessionResourceFile item in client.GetAllFilesMetadataAsync("")) +{ +} +]]> + + + +This sample shows how to call GetAllFilesMetadata. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +foreach (SessionResourceFile item in client.GetAllFilesMetadata("")) +{ +} +]]> +This sample shows how to call GetAllFilesMetadata with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +foreach (SessionResourceFile item in client.GetAllFilesMetadata("")) +{ +} +]]> + + + +This sample shows how to call GetAllFilesMetadataAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +await foreach (BinaryData item in client.GetAllFilesMetadataAsync("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +} +]]> +This sample shows how to call GetAllFilesMetadataAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +await foreach (BinaryData item in client.GetAllFilesMetadataAsync("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +} +]]> + + + +This sample shows how to call GetAllFilesMetadata and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +foreach (BinaryData item in client.GetAllFilesMetadata("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +} +]]> +This sample shows how to call GetAllFilesMetadata with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + +foreach (BinaryData item in client.GetAllFilesMetadata("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/ExecutionType.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/ExecutionType.cs new file mode 100644 index 000000000000..64a3892da907 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/ExecutionType.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 Microsoft.App +{ + /// Execution Type. + public readonly partial struct ExecutionType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ExecutionType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SynchronousValue = "Synchronous"; + private const string AsynchronousValue = "Asynchronous"; + + /// Synchronous. + public static ExecutionType Synchronous { get; } = new ExecutionType(SynchronousValue); + /// Asynchronous. + public static ExecutionType Asynchronous { get; } = new ExecutionType(AsynchronousValue); + /// Determines if two values are the same. + public static bool operator ==(ExecutionType left, ExecutionType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ExecutionType left, ExecutionType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ExecutionType(string value) => new ExecutionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ExecutionType other && Equals(other); + /// + public bool Equals(ExecutionType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/Internal/Argument.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..cd32373dd5c0 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/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 Microsoft.App +{ + 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/microsoft.app/Microsoft.App/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..d1d64bca7cd8 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,398 @@ +// 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 Microsoft.App +{ + internal static class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + 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 ?? WireOptions); + 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/microsoft.app/Microsoft.App/src/Generated/Internal/MultipartFormDataRequestContent.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/Internal/MultipartFormDataRequestContent.cs new file mode 100644 index 000000000000..16cef076ff75 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/Internal/MultipartFormDataRequestContent.cs @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.IO; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Microsoft.App +{ + internal class MultipartFormDataRequestContent : RequestContent + { + private readonly System.Net.Http.MultipartFormDataContent _multipartContent; + private static readonly Random _random = new Random(); + private static readonly char[] _boundaryValues = "0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".ToCharArray(); + + public MultipartFormDataRequestContent() + { + _multipartContent = new System.Net.Http.MultipartFormDataContent(CreateBoundary()); + } + + public string ContentType + { + get + { + return _multipartContent.Headers.ContentType.ToString(); + } + } + + internal HttpContent HttpContent => _multipartContent; + + private static string CreateBoundary() + { + Span chars = new char[70]; + byte[] random = new byte[70]; + _random.NextBytes(random); + int mask = 255 >> 2; + for (int i = 0; i < 70; i++) + { + chars[i] = _boundaryValues[random[i] & mask]; + } + return chars.ToString(); + } + + public void Add(string content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new StringContent(content), name, filename, contentType); + } + + public void Add(int content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(long content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(float content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(double content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(decimal content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(bool content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content ? "true" : "false"; + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(Stream content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new StreamContent(content), name, filename, contentType); + } + + public void Add(byte[] content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new ByteArrayContent(content), name, filename, contentType); + } + + public void Add(BinaryData content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new ByteArrayContent(content.ToArray()), name, filename, contentType); + } + + private void Add(HttpContent content, string name, string filename, string contentType) + { + if (filename != null) + { + Argument.AssertNotNullOrEmpty(filename, nameof(filename)); + AddFilenameHeader(content, name, filename); + } + if (contentType != null) + { + Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); + AddContentTypeHeader(content, contentType); + } + _multipartContent.Add(content, name); + } + + public static void AddFilenameHeader(HttpContent content, string name, string filename) + { + ContentDispositionHeaderValue header = new ContentDispositionHeaderValue("form-data") { Name = name, FileName = filename }; + content.Headers.ContentDisposition = header; + } + + public static void AddContentTypeHeader(HttpContent content, string contentType) + { + MediaTypeHeaderValue header = new MediaTypeHeaderValue(contentType); + content.Headers.ContentType = header; + } + + public override bool TryComputeLength(out long length) + { + if (_multipartContent.Headers.ContentLength is long contentLength) + { + length = contentLength; + return true; + } + length = 0; + return false; + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { +#if NET6_0_OR_GREATER + _multipartContent.CopyTo(stream, default, cancellationToken); +#else +#pragma warning disable AZC0107 + _multipartContent.CopyToAsync(stream).EnsureCompleted(); +#pragma warning restore AZC0107 +#endif + } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { +#if NET6_0_OR_GREATER + await _multipartContent.CopyToAsync(stream, cancellationToken).ConfigureAwait(false); +#else + await _multipartContent.CopyToAsync(stream).ConfigureAwait(false); +#endif + } + + public override void Dispose() + { + _multipartContent.Dispose(); + } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..23de2179ec44 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/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 Microsoft.App +{ + 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/microsoft.app/Microsoft.App/src/Generated/MicrosoftAppClientBuilderExtensions.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/MicrosoftAppClientBuilderExtensions.cs new file mode 100644 index 000000000000..67fe3abcfacf --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/MicrosoftAppClientBuilderExtensions.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core.Extensions; +using Microsoft.App; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class MicrosoftAppClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// The management endpoint of the session pool. + public static IAzureClientBuilder AddAppClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new AppClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddAppClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/MicrosoftAppModelFactory.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/MicrosoftAppModelFactory.cs new file mode 100644 index 000000000000..c0c27d45e8a9 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/MicrosoftAppModelFactory.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace Microsoft.App +{ + /// Model factory for models. + public static partial class MicrosoftAppModelFactory + { + /// Initializes a new instance of . + /// The code input type of the code execution request. + /// The execution type of the code execution request. + /// The network status of the code execution session. + /// The multi array status of the code execution session. + /// The string of the code to execute, based on CodeInputType. + /// Code execution timeout in seconds. + /// Session code execution id. + /// The status of the code execution, indicates whether succeeded or not. + /// The standard output of the code execution. + /// The standard error of the code execution. + /// The result of the code execution. + /// The execution time of the code in milliseconds. + /// A new instance for mocking. + public static SessionCodeExecutionResult SessionCodeExecutionResult(CodeInputType codeInputType = default, ExecutionType executionType = default, NetworkStatus networkStatus = default, MultiArrayStatus multiArrayStatus = default, string code = null, long timeoutInSeconds = default, string id = null, CodeExecutionStatus status = default, string stdout = null, string stderr = null, BinaryData result = null, long executionTimeInMilliseconds = default) + { + return new SessionCodeExecutionResult( + codeInputType, + executionType, + networkStatus, + multiArrayStatus, + code, + timeoutInSeconds, + id, + status, + stdout, + stderr, + result, + executionTimeInMilliseconds, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The name of the file. + /// The size of the file. + /// The date time in RFC3339 format when the file was uploaded. + /// The date time in RFC3339 format when the file was last modified. + /// A new instance for mocking. + public static SessionResourceFile SessionResourceFile(string fileName = null, long sizeInBytes = default, DateTimeOffset createdAt = default, DateTimeOffset lastModifiedAt = default) + { + return new SessionResourceFile(fileName, sizeInBytes, createdAt, lastModifiedAt, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/MultiArrayStatus.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/MultiArrayStatus.cs new file mode 100644 index 000000000000..7f5637dc360b --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/MultiArrayStatus.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 Microsoft.App +{ + /// Multi array status. + public readonly partial struct MultiArrayStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MultiArrayStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string MultiArrayEnabledValue = "MultiArrayEnabled"; + private const string MultiArrayDisabledValue = "MultiArrayDisabled"; + + /// Multi array enabled. + public static MultiArrayStatus MultiArrayEnabled { get; } = new MultiArrayStatus(MultiArrayEnabledValue); + /// Multi array disabled. + public static MultiArrayStatus MultiArrayDisabled { get; } = new MultiArrayStatus(MultiArrayDisabledValue); + /// Determines if two values are the same. + public static bool operator ==(MultiArrayStatus left, MultiArrayStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MultiArrayStatus left, MultiArrayStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MultiArrayStatus(string value) => new MultiArrayStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MultiArrayStatus other && Equals(other); + /// + public bool Equals(MultiArrayStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/NetworkStatus.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/NetworkStatus.cs new file mode 100644 index 000000000000..a389419c1fa8 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/NetworkStatus.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 Microsoft.App +{ + /// Network status. + public readonly partial struct NetworkStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NetworkStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EgressEnabledValue = "EgressEnabled"; + private const string EgressDisabledValue = "EgressDisabled"; + + /// Session egress enabled. + public static NetworkStatus EgressEnabled { get; } = new NetworkStatus(EgressEnabledValue); + /// Session egress disabled. + public static NetworkStatus EgressDisabled { get; } = new NetworkStatus(EgressDisabledValue); + /// Determines if two values are the same. + public static bool operator ==(NetworkStatus left, NetworkStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NetworkStatus left, NetworkStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator NetworkStatus(string value) => new NetworkStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NetworkStatus other && Equals(other); + /// + public bool Equals(NetworkStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionRequest.Serialization.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionRequest.Serialization.cs new file mode 100644 index 000000000000..b6e08c695d53 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionRequest.Serialization.cs @@ -0,0 +1,183 @@ +// 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; +using Azure.Core; + +namespace Microsoft.App +{ + public partial class SessionCodeExecutionRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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(SessionCodeExecutionRequest)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("codeInputType"u8); + writer.WriteStringValue(CodeInputType.ToString()); + writer.WritePropertyName("executionType"u8); + writer.WriteStringValue(ExecutionType.ToString()); + writer.WritePropertyName("networkStatus"u8); + writer.WriteStringValue(NetworkStatus.ToString()); + writer.WritePropertyName("multiArrayStatus"u8); + writer.WriteStringValue(MultiArrayStatus.ToString()); + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + writer.WritePropertyName("timeoutInSeconds"u8); + writer.WriteNumberValue(TimeoutInSeconds); + 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(); + } + + SessionCodeExecutionRequest 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(SessionCodeExecutionRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSessionCodeExecutionRequest(document.RootElement, options); + } + + internal static SessionCodeExecutionRequest DeserializeSessionCodeExecutionRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CodeInputType codeInputType = default; + ExecutionType executionType = default; + NetworkStatus networkStatus = default; + MultiArrayStatus multiArrayStatus = default; + string code = default; + long timeoutInSeconds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("codeInputType"u8)) + { + codeInputType = new CodeInputType(property.Value.GetString()); + continue; + } + if (property.NameEquals("executionType"u8)) + { + executionType = new ExecutionType(property.Value.GetString()); + continue; + } + if (property.NameEquals("networkStatus"u8)) + { + networkStatus = new NetworkStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("multiArrayStatus"u8)) + { + multiArrayStatus = new MultiArrayStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("code"u8)) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("timeoutInSeconds"u8)) + { + timeoutInSeconds = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SessionCodeExecutionRequest( + codeInputType, + executionType, + networkStatus, + multiArrayStatus, + code, + timeoutInSeconds, + 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(SessionCodeExecutionRequest)} does not support writing '{options.Format}' format."); + } + } + + SessionCodeExecutionRequest 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 DeserializeSessionCodeExecutionRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SessionCodeExecutionRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SessionCodeExecutionRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeSessionCodeExecutionRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionRequest.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionRequest.cs new file mode 100644 index 000000000000..a021d7db1e82 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionRequest.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Microsoft.App +{ + /// The request to execute code. + public partial class SessionCodeExecutionRequest + { + /// + /// 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 code input type of the code execution request. + /// The execution type of the code execution request. + /// The network status of the code execution session. + /// The multi array status of the code execution session. + /// The string of the code to execute, based on CodeInputType. + /// Code execution timeout in seconds. + /// is null. + public SessionCodeExecutionRequest(CodeInputType codeInputType, ExecutionType executionType, NetworkStatus networkStatus, MultiArrayStatus multiArrayStatus, string code, long timeoutInSeconds) + { + Argument.AssertNotNull(code, nameof(code)); + + CodeInputType = codeInputType; + ExecutionType = executionType; + NetworkStatus = networkStatus; + MultiArrayStatus = multiArrayStatus; + Code = code; + TimeoutInSeconds = timeoutInSeconds; + } + + /// Initializes a new instance of . + /// The code input type of the code execution request. + /// The execution type of the code execution request. + /// The network status of the code execution session. + /// The multi array status of the code execution session. + /// The string of the code to execute, based on CodeInputType. + /// Code execution timeout in seconds. + /// Keeps track of any properties unknown to the library. + internal SessionCodeExecutionRequest(CodeInputType codeInputType, ExecutionType executionType, NetworkStatus networkStatus, MultiArrayStatus multiArrayStatus, string code, long timeoutInSeconds, IDictionary serializedAdditionalRawData) + { + CodeInputType = codeInputType; + ExecutionType = executionType; + NetworkStatus = networkStatus; + MultiArrayStatus = multiArrayStatus; + Code = code; + TimeoutInSeconds = timeoutInSeconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SessionCodeExecutionRequest() + { + } + + /// The code input type of the code execution request. + public CodeInputType CodeInputType { get; } + /// The execution type of the code execution request. + public ExecutionType ExecutionType { get; } + /// The network status of the code execution session. + public NetworkStatus NetworkStatus { get; } + /// The multi array status of the code execution session. + public MultiArrayStatus MultiArrayStatus { get; } + /// The string of the code to execute, based on CodeInputType. + public string Code { get; } + /// Code execution timeout in seconds. + public long TimeoutInSeconds { get; } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionResult.Serialization.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionResult.Serialization.cs new file mode 100644 index 000000000000..d75ef7b4c9e2 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionResult.Serialization.cs @@ -0,0 +1,247 @@ +// 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; +using Azure.Core; + +namespace Microsoft.App +{ + public partial class SessionCodeExecutionResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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(SessionCodeExecutionResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("codeInputType"u8); + writer.WriteStringValue(CodeInputType.ToString()); + writer.WritePropertyName("executionType"u8); + writer.WriteStringValue(ExecutionType.ToString()); + writer.WritePropertyName("networkStatus"u8); + writer.WriteStringValue(NetworkStatus.ToString()); + writer.WritePropertyName("multiArrayStatus"u8); + writer.WriteStringValue(MultiArrayStatus.ToString()); + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + writer.WritePropertyName("timeoutInSeconds"u8); + writer.WriteNumberValue(TimeoutInSeconds); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("stdout"u8); + writer.WriteStringValue(Stdout); + writer.WritePropertyName("stderr"u8); + writer.WriteStringValue(Stderr); + writer.WritePropertyName("result"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Result); +#else + using (JsonDocument document = JsonDocument.Parse(Result)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("executionTimeInMilliseconds"u8); + writer.WriteNumberValue(ExecutionTimeInMilliseconds); + 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(); + } + + SessionCodeExecutionResult 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(SessionCodeExecutionResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSessionCodeExecutionResult(document.RootElement, options); + } + + internal static SessionCodeExecutionResult DeserializeSessionCodeExecutionResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CodeInputType codeInputType = default; + ExecutionType executionType = default; + NetworkStatus networkStatus = default; + MultiArrayStatus multiArrayStatus = default; + string code = default; + long timeoutInSeconds = default; + string id = default; + CodeExecutionStatus status = default; + string stdout = default; + string stderr = default; + BinaryData result = default; + long executionTimeInMilliseconds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("codeInputType"u8)) + { + codeInputType = new CodeInputType(property.Value.GetString()); + continue; + } + if (property.NameEquals("executionType"u8)) + { + executionType = new ExecutionType(property.Value.GetString()); + continue; + } + if (property.NameEquals("networkStatus"u8)) + { + networkStatus = new NetworkStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("multiArrayStatus"u8)) + { + multiArrayStatus = new MultiArrayStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("code"u8)) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("timeoutInSeconds"u8)) + { + timeoutInSeconds = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new CodeExecutionStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("stdout"u8)) + { + stdout = property.Value.GetString(); + continue; + } + if (property.NameEquals("stderr"u8)) + { + stderr = property.Value.GetString(); + continue; + } + if (property.NameEquals("result"u8)) + { + result = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("executionTimeInMilliseconds"u8)) + { + executionTimeInMilliseconds = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SessionCodeExecutionResult( + codeInputType, + executionType, + networkStatus, + multiArrayStatus, + code, + timeoutInSeconds, + id, + status, + stdout, + stderr, + result, + executionTimeInMilliseconds, + 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(SessionCodeExecutionResult)} does not support writing '{options.Format}' format."); + } + } + + SessionCodeExecutionResult 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 DeserializeSessionCodeExecutionResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SessionCodeExecutionResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SessionCodeExecutionResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeSessionCodeExecutionResult(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionResult.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionResult.cs new file mode 100644 index 000000000000..d4c86aa6be54 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionCodeExecutionResult.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Microsoft.App +{ + /// The result containing the result of the code execution. + public partial class SessionCodeExecutionResult + { + /// + /// 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 code input type of the code execution request. + /// The execution type of the code execution request. + /// The network status of the code execution session. + /// The multi array status of the code execution session. + /// The string of the code to execute, based on CodeInputType. + /// Code execution timeout in seconds. + /// The status of the code execution, indicates whether succeeded or not. + /// The standard output of the code execution. + /// The standard error of the code execution. + /// The result of the code execution. + /// The execution time of the code in milliseconds. + /// , , or is null. + internal SessionCodeExecutionResult(CodeInputType codeInputType, ExecutionType executionType, NetworkStatus networkStatus, MultiArrayStatus multiArrayStatus, string code, long timeoutInSeconds, CodeExecutionStatus status, string stdout, string stderr, BinaryData result, long executionTimeInMilliseconds) + { + Argument.AssertNotNull(code, nameof(code)); + Argument.AssertNotNull(stdout, nameof(stdout)); + Argument.AssertNotNull(stderr, nameof(stderr)); + Argument.AssertNotNull(result, nameof(result)); + + CodeInputType = codeInputType; + ExecutionType = executionType; + NetworkStatus = networkStatus; + MultiArrayStatus = multiArrayStatus; + Code = code; + TimeoutInSeconds = timeoutInSeconds; + Status = status; + Stdout = stdout; + Stderr = stderr; + Result = result; + ExecutionTimeInMilliseconds = executionTimeInMilliseconds; + } + + /// Initializes a new instance of . + /// The code input type of the code execution request. + /// The execution type of the code execution request. + /// The network status of the code execution session. + /// The multi array status of the code execution session. + /// The string of the code to execute, based on CodeInputType. + /// Code execution timeout in seconds. + /// Session code execution id. + /// The status of the code execution, indicates whether succeeded or not. + /// The standard output of the code execution. + /// The standard error of the code execution. + /// The result of the code execution. + /// The execution time of the code in milliseconds. + /// Keeps track of any properties unknown to the library. + internal SessionCodeExecutionResult(CodeInputType codeInputType, ExecutionType executionType, NetworkStatus networkStatus, MultiArrayStatus multiArrayStatus, string code, long timeoutInSeconds, string id, CodeExecutionStatus status, string stdout, string stderr, BinaryData result, long executionTimeInMilliseconds, IDictionary serializedAdditionalRawData) + { + CodeInputType = codeInputType; + ExecutionType = executionType; + NetworkStatus = networkStatus; + MultiArrayStatus = multiArrayStatus; + Code = code; + TimeoutInSeconds = timeoutInSeconds; + Id = id; + Status = status; + Stdout = stdout; + Stderr = stderr; + Result = result; + ExecutionTimeInMilliseconds = executionTimeInMilliseconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SessionCodeExecutionResult() + { + } + + /// The code input type of the code execution request. + public CodeInputType CodeInputType { get; } + /// The execution type of the code execution request. + public ExecutionType ExecutionType { get; } + /// The network status of the code execution session. + public NetworkStatus NetworkStatus { get; } + /// The multi array status of the code execution session. + public MultiArrayStatus MultiArrayStatus { get; } + /// The string of the code to execute, based on CodeInputType. + public string Code { get; } + /// Code execution timeout in seconds. + public long TimeoutInSeconds { get; } + /// Session code execution id. + public string Id { get; } + /// The status of the code execution, indicates whether succeeded or not. + public CodeExecutionStatus Status { get; } + /// The standard output of the code execution. + public string Stdout { get; } + /// The standard error of the code execution. + public string Stderr { get; } + /// + /// The result of the code execution. + /// + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Result { get; } + /// The execution time of the code in milliseconds. + public long ExecutionTimeInMilliseconds { get; } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/SessionResourceFile.Serialization.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionResourceFile.Serialization.cs new file mode 100644 index 000000000000..25e438c3c214 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionResourceFile.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; +using Azure.Core; + +namespace Microsoft.App +{ + public partial class SessionResourceFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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(SessionResourceFile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("fileName"u8); + writer.WriteStringValue(FileName); + writer.WritePropertyName("sizeInBytes"u8); + writer.WriteNumberValue(SizeInBytes); + writer.WritePropertyName("createdAt"u8); + writer.WriteStringValue(CreatedAt, "O"); + writer.WritePropertyName("lastModifiedAt"u8); + writer.WriteStringValue(LastModifiedAt, "O"); + 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(); + } + + SessionResourceFile 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(SessionResourceFile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSessionResourceFile(document.RootElement, options); + } + + internal static SessionResourceFile DeserializeSessionResourceFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileName = default; + long sizeInBytes = default; + DateTimeOffset createdAt = default; + DateTimeOffset lastModifiedAt = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileName"u8)) + { + fileName = property.Value.GetString(); + continue; + } + if (property.NameEquals("sizeInBytes"u8)) + { + sizeInBytes = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + createdAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedAt"u8)) + { + lastModifiedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SessionResourceFile(fileName, sizeInBytes, createdAt, lastModifiedAt, 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(SessionResourceFile)} does not support writing '{options.Format}' format."); + } + } + + SessionResourceFile 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 DeserializeSessionResourceFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SessionResourceFile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SessionResourceFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeSessionResourceFile(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/SessionResourceFile.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionResourceFile.cs new file mode 100644 index 000000000000..15e615a6a97b --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionResourceFile.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Microsoft.App +{ + /// Code execution file resource. + public partial class SessionResourceFile + { + /// + /// 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 name of the file. + /// The size of the file. + /// The date time in RFC3339 format when the file was uploaded. + /// The date time in RFC3339 format when the file was last modified. + /// is null. + internal SessionResourceFile(string fileName, long sizeInBytes, DateTimeOffset createdAt, DateTimeOffset lastModifiedAt) + { + Argument.AssertNotNull(fileName, nameof(fileName)); + + FileName = fileName; + SizeInBytes = sizeInBytes; + CreatedAt = createdAt; + LastModifiedAt = lastModifiedAt; + } + + /// Initializes a new instance of . + /// The name of the file. + /// The size of the file. + /// The date time in RFC3339 format when the file was uploaded. + /// The date time in RFC3339 format when the file was last modified. + /// Keeps track of any properties unknown to the library. + internal SessionResourceFile(string fileName, long sizeInBytes, DateTimeOffset createdAt, DateTimeOffset lastModifiedAt, IDictionary serializedAdditionalRawData) + { + FileName = fileName; + SizeInBytes = sizeInBytes; + CreatedAt = createdAt; + LastModifiedAt = lastModifiedAt; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SessionResourceFile() + { + } + + /// The name of the file. + public string FileName { get; } + /// The size of the file. + public long SizeInBytes { get; } + /// The date time in RFC3339 format when the file was uploaded. + public DateTimeOffset CreatedAt { get; } + /// The date time in RFC3339 format when the file was last modified. + public DateTimeOffset LastModifiedAt { get; } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/SessionResourceFiles.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionResourceFiles.cs new file mode 100644 index 000000000000..555237e14d52 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/SessionResourceFiles.cs @@ -0,0 +1,702 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Microsoft.App +{ + // Data plane generated sub-client. + /// The SessionResourceFiles sub-client. + public partial class SessionResourceFiles + { + private static readonly string[] AuthorizationScopes = new string[] { "https://dynamicsessions.io/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of SessionResourceFiles for mocking. + protected SessionResourceFiles() + { + } + + /// Initializes a new instance of SessionResourceFiles. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// The management endpoint of the session pool. + /// The API version to use for this operation. + internal SessionResourceFiles(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get the file resource. + /// The name of the file. + /// The identifier of the session. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetFileMetadataAsync(string fileName, string identifier, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetFileMetadataAsync(fileName, identifier, context).ConfigureAwait(false); + return Response.FromValue(SessionResourceFile.FromResponse(response), response); + } + + /// Get the file resource. + /// The name of the file. + /// The identifier of the session. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetFileMetadata(string fileName, string identifier, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetFileMetadata(fileName, identifier, context); + return Response.FromValue(SessionResourceFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get the file resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the file. + /// The identifier of the session. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetFileMetadataAsync(string fileName, string identifier, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + + using var scope = ClientDiagnostics.CreateScope("SessionResourceFiles.GetFileMetadata"); + scope.Start(); + try + { + using HttpMessage message = CreateGetFileMetadataRequest(fileName, identifier, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get the file resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the file. + /// The identifier of the session. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetFileMetadata(string fileName, string identifier, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + + using var scope = ClientDiagnostics.CreateScope("SessionResourceFiles.GetFileMetadata"); + scope.Start(); + try + { + using HttpMessage message = CreateGetFileMetadataRequest(fileName, identifier, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete the file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the file. + /// The identifier of the session. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteFileAsync(string fileName, string identifier, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + + using var scope = ClientDiagnostics.CreateScope("SessionResourceFiles.DeleteFile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteFileRequest(fileName, identifier, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete the file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the file. + /// The identifier of the session. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response DeleteFile(string fileName, string identifier, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + + using var scope = ClientDiagnostics.CreateScope("SessionResourceFiles.DeleteFile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteFileRequest(fileName, identifier, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Download the file. + /// The name of the file. + /// The identifier of the session. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> DownloadFileAsync(string fileName, string identifier, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await DownloadFileAsync(fileName, identifier, context).ConfigureAwait(false); + return Response.FromValue(response.Content, response); + } + + /// Download the file. + /// The name of the file. + /// The identifier of the session. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response DownloadFile(string fileName, string identifier, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = DownloadFile(fileName, identifier, context); + return Response.FromValue(response.Content, response); + } + + /// + /// [Protocol Method] Download the file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the file. + /// The identifier of the session. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DownloadFileAsync(string fileName, string identifier, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + + using var scope = ClientDiagnostics.CreateScope("SessionResourceFiles.DownloadFile"); + scope.Start(); + try + { + using HttpMessage message = CreateDownloadFileRequest(fileName, identifier, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Download the file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the file. + /// The identifier of the session. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response DownloadFile(string fileName, string identifier, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + + using var scope = ClientDiagnostics.CreateScope("SessionResourceFiles.DownloadFile"); + scope.Start(); + try + { + using HttpMessage message = CreateDownloadFileRequest(fileName, identifier, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Upload a file to a session. + /// The name of the file. + /// The identifier of the session. + /// The file to upload. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> UploadFileAsync(string fileName, string identifier, Stream file, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(file, nameof(file)); + + UploadFileRequest uploadFileRequest = new UploadFileRequest(file, null); + using MultipartFormDataRequestContent content = uploadFileRequest.ToMultipartRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UploadFileAsync(fileName, identifier, content, content.ContentType, context).ConfigureAwait(false); + return Response.FromValue(SessionResourceFile.FromResponse(response), response); + } + + /// Upload a file to a session. + /// The name of the file. + /// The identifier of the session. + /// The file to upload. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response UploadFile(string fileName, string identifier, Stream file, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(file, nameof(file)); + + UploadFileRequest uploadFileRequest = new UploadFileRequest(file, null); + using MultipartFormDataRequestContent content = uploadFileRequest.ToMultipartRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UploadFile(fileName, identifier, content, content.ContentType, context); + return Response.FromValue(SessionResourceFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Upload a file to a session. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the file. + /// The identifier of the session. + /// The content to send as the body of the request. + /// The content type for the operation. Always multipart/form-data for this operation. Allowed values: "multipart/form-data". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task UploadFileAsync(string fileName, string identifier, RequestContent content, string contentType, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("SessionResourceFiles.UploadFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadFileRequest(fileName, identifier, content, contentType, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Upload a file to a session. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the file. + /// The identifier of the session. + /// The content to send as the body of the request. + /// The content type for the operation. Always multipart/form-data for this operation. Allowed values: "multipart/form-data". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response UploadFile(string fileName, string identifier, RequestContent content, string contentType, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(identifier, nameof(identifier)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("SessionResourceFiles.UploadFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadFileRequest(fileName, identifier, content, contentType, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List the file resources. + /// The identifier of the session. + /// The cancellation token to use. + /// is null. + /// + public virtual AsyncPageable GetAllFilesMetadataAsync(string identifier, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetAllFilesMetadataRequest(identifier, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetAllFilesMetadataNextPageRequest(nextLink, identifier, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => SessionResourceFile.DeserializeSessionResourceFile(e), ClientDiagnostics, _pipeline, "SessionResourceFiles.GetAllFilesMetadata", "value", "nextLink", context); + } + + /// List the file resources. + /// The identifier of the session. + /// The cancellation token to use. + /// is null. + /// + public virtual Pageable GetAllFilesMetadata(string identifier, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetAllFilesMetadataRequest(identifier, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetAllFilesMetadataNextPageRequest(nextLink, identifier, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => SessionResourceFile.DeserializeSessionResourceFile(e), ClientDiagnostics, _pipeline, "SessionResourceFiles.GetAllFilesMetadata", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the file resources. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the session. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetAllFilesMetadataAsync(string identifier, RequestContext context) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetAllFilesMetadataRequest(identifier, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetAllFilesMetadataNextPageRequest(nextLink, identifier, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "SessionResourceFiles.GetAllFilesMetadata", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the file resources. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the session. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetAllFilesMetadata(string identifier, RequestContext context) + { + Argument.AssertNotNull(identifier, nameof(identifier)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetAllFilesMetadataRequest(identifier, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetAllFilesMetadataNextPageRequest(nextLink, identifier, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "SessionResourceFiles.GetAllFilesMetadata", "value", "nextLink", context); + } + + internal HttpMessage CreateGetAllFilesMetadataRequest(string identifier, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files", false); + uri.AppendQuery("identifier", identifier, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetFileMetadataRequest(string fileName, string identifier, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendQuery("identifier", identifier, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDeleteFileRequest(string fileName, string identifier, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendQuery("identifier", identifier, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDownloadFileRequest(string fileName, string identifier, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendPath("/download", false); + uri.AppendQuery("identifier", identifier, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUploadFileRequest(string fileName, string identifier, RequestContent content, string contentType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendPath(":uploadFile", false); + uri.AppendQuery("identifier", identifier, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", contentType); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAllFilesMetadataNextPageRequest(string nextLink, string identifier, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + 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"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/UploadFileRequest.Serialization.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/UploadFileRequest.Serialization.cs new file mode 100644 index 000000000000..824ef5d4d60e --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/UploadFileRequest.Serialization.cs @@ -0,0 +1,168 @@ +// 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.IO; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Microsoft.App +{ + internal partial class UploadFileRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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(UploadFileRequest)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(global::System.BinaryData.FromStream(File)); +#else + using (JsonDocument document = JsonDocument.Parse(BinaryData.FromStream(File))) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + 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(); + } + + UploadFileRequest 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(UploadFileRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUploadFileRequest(document.RootElement, options); + } + + internal static UploadFileRequest DeserializeUploadFileRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Stream file = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file"u8)) + { + file = BinaryData.FromString(property.Value.GetRawText()).ToStream(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UploadFileRequest(file, serializedAdditionalRawData); + } + + private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + { + using MultipartFormDataRequestContent content = ToMultipartRequestContent(); + using MemoryStream stream = new MemoryStream(); + content.WriteTo(stream); + if (stream.Position > int.MaxValue) + { + return BinaryData.FromStream(stream); + } + else + { + return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); + } + } + + internal virtual MultipartFormDataRequestContent ToMultipartRequestContent() + { + MultipartFormDataRequestContent content = new MultipartFormDataRequestContent(); + content.Add(File, "file", "file", "application/octet-stream"); + return content; + } + + 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); + case "MFD": + return SerializeMultipart(options); + default: + throw new FormatException($"The model {nameof(UploadFileRequest)} does not support writing '{options.Format}' format."); + } + } + + UploadFileRequest 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 DeserializeUploadFileRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UploadFileRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UploadFileRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUploadFileRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Generated/UploadFileRequest.cs b/sdk/microsoft.app/Microsoft.App/src/Generated/UploadFileRequest.cs new file mode 100644 index 000000000000..fea122759a7e --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Generated/UploadFileRequest.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.IO; + +namespace Microsoft.App +{ + /// The UploadFileRequest. + internal partial class UploadFileRequest + { + /// + /// 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 file to upload. + /// is null. + internal UploadFileRequest(Stream file) + { + Argument.AssertNotNull(file, nameof(file)); + + File = file; + } + + /// Initializes a new instance of . + /// The file to upload. + /// Keeps track of any properties unknown to the library. + internal UploadFileRequest(Stream file, IDictionary serializedAdditionalRawData) + { + File = file; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal UploadFileRequest() + { + } + + /// The file to upload. + public Stream File { get; } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/src/Microsoft.App.csproj b/sdk/microsoft.app/Microsoft.App/src/Microsoft.App.csproj new file mode 100644 index 000000000000..323243ab0c36 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Microsoft.App.csproj @@ -0,0 +1,19 @@ + + + This is the Microsoft.App client library for developing .NET applications with rich experience. + Azure SDK Code Generation Microsoft.App for Azure Data Plane + 1.0.0-beta.1 + Microsoft.App + $(RequiredTargetFrameworks) + true + + + + + + + + + + + diff --git a/sdk/microsoft.app/Microsoft.App/src/Properties/AssemblyInfo.cs b/sdk/microsoft.app/Microsoft.App/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..dedf0ce3c8e8 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/src/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Microsoft.App.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/microsoft.app/Microsoft.App/tests/Generated/Samples/Samples_AppClient.cs b/sdk/microsoft.app/Microsoft.App/tests/Generated/Samples/Samples_AppClient.cs new file mode 100644 index 000000000000..3734acb417bb --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/tests/Generated/Samples/Samples_AppClient.cs @@ -0,0 +1,372 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Microsoft.App.Samples +{ + public partial class Samples_AppClient + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_App_ExecuteCode_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + codeInputType = "Inline", + executionType = "Synchronous", + networkStatus = "EgressEnabled", + multiArrayStatus = "MultiArrayEnabled", + code = "", + timeoutInSeconds = 1234L, + }); + Response response = client.ExecuteCode("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("codeInputType").ToString()); + Console.WriteLine(result.GetProperty("executionType").ToString()); + Console.WriteLine(result.GetProperty("networkStatus").ToString()); + Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); + Console.WriteLine(result.GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("stdout").ToString()); + Console.WriteLine(result.GetProperty("stderr").ToString()); + Console.WriteLine(result.GetProperty("result").ToString()); + Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_App_ExecuteCode_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + codeInputType = "Inline", + executionType = "Synchronous", + networkStatus = "EgressEnabled", + multiArrayStatus = "MultiArrayEnabled", + code = "", + timeoutInSeconds = 1234L, + }); + Response response = await client.ExecuteCodeAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("codeInputType").ToString()); + Console.WriteLine(result.GetProperty("executionType").ToString()); + Console.WriteLine(result.GetProperty("networkStatus").ToString()); + Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); + Console.WriteLine(result.GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("stdout").ToString()); + Console.WriteLine(result.GetProperty("stderr").ToString()); + Console.WriteLine(result.GetProperty("result").ToString()); + Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_App_ExecuteCode_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + SessionCodeExecutionRequest codeExecutionRequest = new SessionCodeExecutionRequest( + CodeInputType.Inline, + ExecutionType.Synchronous, + NetworkStatus.EgressEnabled, + MultiArrayStatus.MultiArrayEnabled, + "", + 1234L); + Response response = client.ExecuteCode("", codeExecutionRequest); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_App_ExecuteCode_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + SessionCodeExecutionRequest codeExecutionRequest = new SessionCodeExecutionRequest( + CodeInputType.Inline, + ExecutionType.Synchronous, + NetworkStatus.EgressEnabled, + MultiArrayStatus.MultiArrayEnabled, + "", + 1234L); + Response response = await client.ExecuteCodeAsync("", codeExecutionRequest); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_App_ExecuteCode_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + codeInputType = "Inline", + executionType = "Synchronous", + networkStatus = "EgressEnabled", + multiArrayStatus = "MultiArrayEnabled", + code = "", + timeoutInSeconds = 1234L, + }); + Response response = client.ExecuteCode("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("codeInputType").ToString()); + Console.WriteLine(result.GetProperty("executionType").ToString()); + Console.WriteLine(result.GetProperty("networkStatus").ToString()); + Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); + Console.WriteLine(result.GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("stdout").ToString()); + Console.WriteLine(result.GetProperty("stderr").ToString()); + Console.WriteLine(result.GetProperty("result").ToString()); + Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_App_ExecuteCode_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + codeInputType = "Inline", + executionType = "Synchronous", + networkStatus = "EgressEnabled", + multiArrayStatus = "MultiArrayEnabled", + code = "", + timeoutInSeconds = 1234L, + }); + Response response = await client.ExecuteCodeAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("codeInputType").ToString()); + Console.WriteLine(result.GetProperty("executionType").ToString()); + Console.WriteLine(result.GetProperty("networkStatus").ToString()); + Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); + Console.WriteLine(result.GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("stdout").ToString()); + Console.WriteLine(result.GetProperty("stderr").ToString()); + Console.WriteLine(result.GetProperty("result").ToString()); + Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_App_ExecuteCode_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + SessionCodeExecutionRequest codeExecutionRequest = new SessionCodeExecutionRequest( + CodeInputType.Inline, + ExecutionType.Synchronous, + NetworkStatus.EgressEnabled, + MultiArrayStatus.MultiArrayEnabled, + "", + 1234L); + Response response = client.ExecuteCode("", codeExecutionRequest); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_App_ExecuteCode_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + SessionCodeExecutionRequest codeExecutionRequest = new SessionCodeExecutionRequest( + CodeInputType.Inline, + ExecutionType.Synchronous, + NetworkStatus.EgressEnabled, + MultiArrayStatus.MultiArrayEnabled, + "", + 1234L); + Response response = await client.ExecuteCodeAsync("", codeExecutionRequest); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_App_GetCodeExecutionResult_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + Response response = client.GetCodeExecutionResult("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("codeInputType").ToString()); + Console.WriteLine(result.GetProperty("executionType").ToString()); + Console.WriteLine(result.GetProperty("networkStatus").ToString()); + Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); + Console.WriteLine(result.GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("stdout").ToString()); + Console.WriteLine(result.GetProperty("stderr").ToString()); + Console.WriteLine(result.GetProperty("result").ToString()); + Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_App_GetCodeExecutionResult_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + Response response = await client.GetCodeExecutionResultAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("codeInputType").ToString()); + Console.WriteLine(result.GetProperty("executionType").ToString()); + Console.WriteLine(result.GetProperty("networkStatus").ToString()); + Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); + Console.WriteLine(result.GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("stdout").ToString()); + Console.WriteLine(result.GetProperty("stderr").ToString()); + Console.WriteLine(result.GetProperty("result").ToString()); + Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_App_GetCodeExecutionResult_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + Response response = client.GetCodeExecutionResult("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_App_GetCodeExecutionResult_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + Response response = await client.GetCodeExecutionResultAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_App_GetCodeExecutionResult_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + Response response = client.GetCodeExecutionResult("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("codeInputType").ToString()); + Console.WriteLine(result.GetProperty("executionType").ToString()); + Console.WriteLine(result.GetProperty("networkStatus").ToString()); + Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); + Console.WriteLine(result.GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("stdout").ToString()); + Console.WriteLine(result.GetProperty("stderr").ToString()); + Console.WriteLine(result.GetProperty("result").ToString()); + Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_App_GetCodeExecutionResult_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + Response response = await client.GetCodeExecutionResultAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("codeInputType").ToString()); + Console.WriteLine(result.GetProperty("executionType").ToString()); + Console.WriteLine(result.GetProperty("networkStatus").ToString()); + Console.WriteLine(result.GetProperty("multiArrayStatus").ToString()); + Console.WriteLine(result.GetProperty("code").ToString()); + Console.WriteLine(result.GetProperty("timeoutInSeconds").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("stdout").ToString()); + Console.WriteLine(result.GetProperty("stderr").ToString()); + Console.WriteLine(result.GetProperty("result").ToString()); + Console.WriteLine(result.GetProperty("executionTimeInMilliseconds").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_App_GetCodeExecutionResult_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + Response response = client.GetCodeExecutionResult("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_App_GetCodeExecutionResult_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + AppClient client = new AppClient(endpoint, credential); + + Response response = await client.GetCodeExecutionResultAsync("", ""); + } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/tests/Generated/Samples/Samples_SessionResourceFiles.cs b/sdk/microsoft.app/Microsoft.App/tests/Generated/Samples/Samples_SessionResourceFiles.cs new file mode 100644 index 000000000000..31b7de9a9e45 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/tests/Generated/Samples/Samples_SessionResourceFiles.cs @@ -0,0 +1,537 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.IO; +using System.Text.Json; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Microsoft.App.Samples +{ + public partial class Samples_SessionResourceFiles + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFile_GetFileMetadata_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.GetFileMetadata("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFile_GetFileMetadata_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.GetFileMetadataAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFile_GetFileMetadata_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.GetFileMetadata("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFile_GetFileMetadata_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.GetFileMetadataAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFile_GetFileMetadata_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.GetFileMetadata("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFile_GetFileMetadata_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.GetFileMetadataAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFile_GetFileMetadata_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.GetFileMetadata("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFile_GetFileMetadata_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.GetFileMetadataAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFile_DeleteFile_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.DeleteFile("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFile_DeleteFile_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.DeleteFileAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFile_DeleteFile_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.DeleteFile("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFile_DeleteFile_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.DeleteFileAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFiles_DownloadFile_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.DownloadFile("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFiles_DownloadFile_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.DownloadFileAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFiles_DownloadFile_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.DownloadFile("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFiles_DownloadFile_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.DownloadFileAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFiles_DownloadFile_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.DownloadFile("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFiles_DownloadFile_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.DownloadFileAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFiles_DownloadFile_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.DownloadFile("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFiles_DownloadFile_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.DownloadFileAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFiles_UploadFile_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + using RequestContent content = RequestContent.Create(new + { + file = File.OpenRead(""), + }); + Response response = client.UploadFile("", "", content, "multipart/form-data"); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFiles_UploadFile_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + using RequestContent content = RequestContent.Create(new + { + file = File.OpenRead(""), + }); + Response response = await client.UploadFileAsync("", "", content, "multipart/form-data"); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFiles_UploadFile_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.UploadFile("", "", null); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFiles_UploadFile_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.UploadFileAsync("", "", null); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFiles_UploadFile_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + using RequestContent content = RequestContent.Create(new + { + file = File.OpenRead(""), + }); + Response response = client.UploadFile("", "", content, "multipart/form-data"); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFiles_UploadFile_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + using RequestContent content = RequestContent.Create(new + { + file = File.OpenRead(""), + }); + Response response = await client.UploadFileAsync("", "", content, "multipart/form-data"); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFiles_UploadFile_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = client.UploadFile("", "", null); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFiles_UploadFile_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + Response response = await client.UploadFileAsync("", "", null); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFile_GetAllFilesMetadata_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + foreach (BinaryData item in client.GetAllFilesMetadata("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFile_GetAllFilesMetadata_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + await foreach (BinaryData item in client.GetAllFilesMetadataAsync("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFile_GetAllFilesMetadata_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + foreach (SessionResourceFile item in client.GetAllFilesMetadata("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFile_GetAllFilesMetadata_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + await foreach (SessionResourceFile item in client.GetAllFilesMetadataAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFile_GetAllFilesMetadata_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + foreach (BinaryData item in client.GetAllFilesMetadata("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFile_GetAllFilesMetadata_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + await foreach (BinaryData item in client.GetAllFilesMetadataAsync("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + Console.WriteLine(result.GetProperty("sizeInBytes").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("lastModifiedAt").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SessionResourceFile_GetAllFilesMetadata_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + foreach (SessionResourceFile item in client.GetAllFilesMetadata("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SessionResourceFile_GetAllFilesMetadata_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SessionResourceFiles client = new AppClient(endpoint, credential).GetSessionResourceFilesClient(); + + await foreach (SessionResourceFile item in client.GetAllFilesMetadataAsync("")) + { + } + } + } +} diff --git a/sdk/microsoft.app/Microsoft.App/tests/Microsoft.App.Tests.csproj b/sdk/microsoft.app/Microsoft.App/tests/Microsoft.App.Tests.csproj new file mode 100644 index 000000000000..5daa8d1b7c6c --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/tests/Microsoft.App.Tests.csproj @@ -0,0 +1,19 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + diff --git a/sdk/microsoft.app/Microsoft.App/tsp-location.yaml b/sdk/microsoft.app/Microsoft.App/tsp-location.yaml new file mode 100644 index 000000000000..99aefa42fda6 --- /dev/null +++ b/sdk/microsoft.app/Microsoft.App/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/app/Microsoft.App +commit: 550e34355d3111c5b7b68a6b3d3792bcd0f106a1 +repo: Azure/azure-rest-api-specs +additionalDirectories: